CSC211 LAB 7
- Please fill out this survey http://www.itd.depaul.edu/quickdata2/viewwebform.asp?id=4669
- Modify the hilo game so the user has at most 5 tries to guess the number.
- Modify the hilo game as follows
- Declare an integer variable named diff.
- Assign to diff the absolute value of (num - guess). See Math class for absolute value function.
- If diff is 0, guess is correct and output the appropriate message.
- If diff is not 0 then:
- If diff is greater that or equal to 50. Ouput the guess is VERY HIGH (If guess is greater than num). Output VERY LOW (if guess is less than num).
- If diff is greater than or equal to 30 and less than 50. Output the Guess is HIGH ((If guess is greater than num). Output LOW (if guess is less than num).
- If diff is greater than or equal to 15 and less than 30. Output the Guess is MODERATELY HIGH ((If guess is greater than num). Output MODERATELY LOW (if guess is less than num).
- If diff is greater than 0 and less than 15. Output the Guess is SOMEWHAT HIGH ((If guess is greater than num). Output SOMEWHAT LOW (if guess is less than num).
- Look over CalculatorA and CalculatorB. Get the code for CalculatorC.java
at the course homepage. Study the code. Compile and run the program a couple of times. Add a case statement to include the modulus operator.
See lecture notes 1 about the modulus operator.
- Add the following methods to ClassMethodTest.java.
- Write a method that returns the average of three integers. Here is what the method heading should look like.
public static double averageOfThree(int num1, int num2, int num3)
- Write a method called
isValid
that will input an integer and return true or false whether or not that value is a valid score. A valid score, is a score between 0 and 100 (inclusive)
- Write a method called
powersOfTwo
that prints the first 10 powers of two. The method takes no parameters and doesn't return anything.