A good answer might be:

There are some syntax errors:

long good-by ;  // bad identifier: "-" not allowed

short shrift = 0;  // OK

double bubble = 0, toil= 9, trouble = 8 // missing ";" at end.

byte the bullet ;    // bad identifier: can't contain a space

int  double;    // reserved word

char thisMustBeTooLong  ;   // OK in syntax, but a poor choice 
                            // for a variable name

int  8ball;    // can't start with a digit

Example Program

Here is another example program, containing several variable declarations.

class example
{
  public static void main ( String[] args )
  {
    long   hoursWorked = 40;    
    double payRate     = 10.0, taxRate = 0.10;    

    System.out.println("Hours Worked: " + hoursWorked );
    System.out.println("pay Amount  : " + (hoursWorked * payRate) );
    System.out.println("tax Amount  : " + (hoursWorked * payRate * taxRate) );
  }
}

The character * means multiply. In the program, (hoursWorked * payRate) means to multiply the number stored in hoursWorked by the number stored in payRate.

When it follows a character string, + means to add characters to the end of the character string. So  "Hours Worked: " + hoursWorked   makes a character string starting with "Hours Worked: " and ending with characters for the value of hoursWorked. The program will print out:

Hours Worked: 40
pay Amount  : 400.0
tax Amount  : 40.0

The program illustrates an

Important Idea: To use the value stored in a variable, just use the name of the variable.

So, for example, in the first System.out.println statement, the variable hoursWorked was used. This means "go get the value inside hoursWorked and use that value here.

Remember that if you want to run these programs, you can "copy" them from your www browser, "paste" them into the window of Notepad, and proceed as usual. (See the chapter "Running Example Programs without Typing" in these Notes.) If you are on a Unix system you can do similar things with your browser and editor window.

QUESTION 7:

Why did the program print the first "40" without a decimal point, but printed the second one with a decimal point as "40.0" ?