Sale!

EECS2500 Project 1, Programming Review solution

$30.00 $25.50

Category:

Description

5/5 - (8 votes)

1. Coding Guidelines (20 points) (a) (10 points) Rewrite the following according to the coding
guidelines. (b) (10 points) Mention 5 features of this class that violate the coding guidelines.
char c1;
c1 = GetChoice();
switch (c1)
{
case ‘a’:
case ‘A’:
OptionA();
break;
case ‘i’:
case ‘I’:
OptionI();
break;
case ‘w’:
case ‘W’:
ProcessOptionW();
break;
default:
println(“Not a valid choice\n)”;
}
2. Control Structures (40 points) 20 points for correctness, 20 for following the coding guidelines.
Write a program to generate a random number from 1 to 100 and keep it as a secret number. The
program will then check if a user can guess the secret number. The user can continue guessing the
number until the number is found or the user can enter 0, which will terminate the program. Name
this program SecretNumber.java.

Each time the user makes a guess, the program will report as below:

1. Way Too High or Way Too Low (more than 30 off)
2. High or Low (between 10 and 30 points off)
3. A Little High or A Little Low (less than 10 points off)
If secret number is 74 and the user enters 26, the program will print “Way too Low”. If the user then
says 65, then the program will print “A Little Low”.
3. Classes (40 points). 20 points for correctness, 20 for following the coding guidelines. Design
and implement a class called Die (for a die in a pair of dice). Include a constructor for a die
(which will set its value as null or -1), methods to set and get the individual die values, and a
method to print the die. For instance, a 5 will print as
* *
*
* *

Create a driver class called CreatePairOfDice to instantiate and print a pair of dice. The value of
each die should be a randomly generated integer from 1 to 6. You must use Math.random().
4. GUI Interfaces (30 points). Write a program using Java FX graphics to display a screen like the
following screen. There is no need to provide any actions when a button is pressed. You may
improve the colors or graphics.