জাভা প্রোগ্রামিং পর্ব-০৩ (Programming Exercises)

-----------------------------------------------------------

Solution : 1.1 File name : DisplayThreeMessage.java
  Source Code:

public class DisplayThreeMessage {

public static void main (String []args){

System.out.println("Welcome to java.");

System.out.println("Welcome to computer science.");

System.out.println("Programming is fun.");

}

}



Solution : 1.2 File name : DisplayingFiveMessages.java

Source Code:

public class DisplayingFiveMessages {

public static void main (String []args){

System.out.println ("Welcome to java");

System.out.println ("Welcome to java");

System.out.println ("Welcome to java");

System.out.println ("Welcome to java");

System.out.println ("Welcome to java");

}

}



Solution : 1.3 File name : Displayingpattern.java

Source Code:

public class Displayingpattern {

public static void main (String []args){

System.out.println("   J      A     V     V    A");        

System.out.println("   J     A A     V   V   A A");

System.out.println("J  J   AAAAA    V V   AAAAA");

System.out.println(" J J  A       A    V    A      A");

}

}



Solution : 1.4 File name : Printingtable.java

Source Code:

public class Printingtable {

public static void main (String []args){

System.out.println("a   a^2   a^3");                       

System.out.println("1   1     1");

System.out.println("2   4     8");

System.out.println("3   9     27");

System.out.println("4   16    64");

}

}



Solution : 1.5 File name : ComputingExpressions.java

Source Code:

public class ComputingExpressions {

                        public static void main (String []args){

                                    System.out.println((9.5*4.5-2.5*3)/(45.5-3.5));

                        }

}



Solution : 1.6 File name : SummationOfSeries.java

Source Code:

import java.util.*;

public class SummationOfSeries{

public static void main (String []args){

                                     int i, sum=0;

                                    for(i=1; i<=9; i++)

                                                sum=sum+i;

                                     System.out.print(+sum);

}

}



Solution : 1.7 File name : Approximating.java

Source Code:

import java.util.*;

public class Approximating{

                public static void main (String []args){

                        double i, j=1, sum=0;

                         for(i=1; i<=3; i=i+2)

                              if(j%2==1){

                                    sum=(sum+(1/i));

                                    j++;

                                }

                              else{

                                    sum=(sum-(1/i));

                                    j++;

                                   }

                 System.out.println(+sum*4);

}

}
 

Loading
Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Flying Twitter Bird Widget By ICT Sparkle