Q1 Output Questions

1. Change your first program so that it prints out your name.

2. Run the following program:

public class ASCIIart
{
   public static void main (String args [])
   {  new ASCIIart();
   }


	public ASCIIart()
   {
   System.out.println (" A Square: \n");
   System.out.println (" *****");
   System.out.println (" *****");
   System.out.println (" *****");
   System.out.println (" *****");
   
   System.out.println ("\n \n A Bear: \n");
   System.out.println ("    ___");
   System.out.println ("  {~._.~}");
   System.out.println ("  _( Y )_ ");
   System.out.println (" (:_~*~_:)");
   System.out.println ("  (_)-(_)");
   }
 }

3. What does System.out.println("\n"); do? Is it the same as System.out.println("");?

4. Make a house on the screen.

Show Ms. Gorski the above when you are done.

Debugging and Variables - A Short Exercise

5: There are 5 distinct errors in the following java program, what are they?
 

import java.io //line1

public class  //line2
{ //line 3
   public static main (String args[]) //line 4
   { int h; //line 5
     h=IBIO.inputDouble("Please enter a decimal:"); //line 6
      System.out.println(num); //line 7
   } //line 8
} //line 9

6. Which type of variable is used for each of the following situations? (int, double, char, String)
(a) To hold a person's name
(b) To hold the answer to "Enter the first letter of your name"
(c) The hold the price of a hamburger
(d) To hold the number of students in a class
(e) To hold the answer to "Is this correct (y/n)?"
(f) To hold the amount of tax on a purchase
(g) To hold the mark someone got on a test
(h) To hold the number of fish in a tank
(i) To hold the day of the month
(k) To hold "Turner Fenton"