In class assignment #1


/**
 * Type in the following program and run it. Then make the following additions:
 *  1) Have the computer ask you for your class (Freshman, Sophomore, Junior, Senior
 *  2) Have the computer ask you for your favorite color   
 *  3) Have the computer ask you for your favorite movie
 *  After collecting all this information, the computer should print out the info as demonstrated below
 * 
 *  Name: Harry Jones
 *  Class: Sophomore
 *  Favorite Color: Green
 *  Favorite Movie: Jaws
 * 
 *  Have the computer print out a blank line before it asks for another person! Make sure you demo the program !
 *
 */



import java.util.Scanner;
public class FirstProgram
{
   public static void main(String [] args)
   {
       Scanner sc=new Scanner(System.in);
       String myName;
      
       while(true)
       {
           System.out.println("Enter your name ");
           myName=sc.nextLine();
          
           System.out.println("Hello "+myName+" welcome to your first interactive program");
        }
   
      
    }
}

In class assignment #2

First, try to predict the outcome of the following program. Then type in the program and compare your output with what you expected.
How can you make the program behave as you like ? You must explain your answers and fix!

public class SecondProgram
{
   public static void main(String [] args)
   {
       int top=13;
       int bottom = 3;

       System.out.println( top / bottom);

       double bottom2 = 3.0;
       System.out.println( top / bottom2 );

       System.out.println ( 7 / 23 );

       float newNumber = 3.7 ;         //this will give an error. Why ???
      
      
    }
}