Put all of the programs (questions 3 to 5) in one file. Put appropriate titles between the sections.
1. The following snippet of code compiles but
has a syntax error. Find the error.
if (Score == 1)
System.out.println(“You
got a hole in one”);
else;
System.out.println(“You
didn’t get a hole in one”);
2. The following snippet of code compiles but
has a syntax error. Find the error.
int x = 0;
if (x=1)
System.out.println(“X
is one”);
3. Create a program that asks for a number and depending of the value prints POSITIVE, NEGATIVE or ZERO.
4. Write a program that asks users to enter their age. If the age is eighteen or more, the program should print OLD ENOUGH TO VOTE. Otherwise, it should print the number of years before voting is possible (e.g. WAIT 4 YEARS TO VOTE).
5. Write a program that asks the user for the
number of strokes on one hole of a par 5 golf games and then displays an appropriate
message according to the following table:
1
Hole in one!
2
Double Eagle
3
Eagle
4
Birdie
5
Par
6
Bogey
7
Double Bogey
8
Triple Bogey
9+ Disaster