Friday, September 1, 2017

Chapter One Exercise Five

//Write a program to compute an expression

public class Exercise105{
   public static void main(String [] args) {

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

Chapter One Exercise Four

//Print a table
public class Exercise104{
   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");
   }
}  

Chapter One Exercise Three

//Write a program that displays a pattern

public class Exercise103 {
   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");
   }
}


Chapter One Exercise Two

//Write a program that displays Welcome to Java five times.

public class Exercise102{
   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");
   }
}

Chapter one Exercise One

//Write a program that displays Welcome to Java, Welcome to
//Computer Science, and Programming is Fun

public class Exercise101{
   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!");
   }
}