Question: 3. Write a small math game according to the following requirements. (updated version of in-class practice 01/30/2019) 1) Ask user to choose one operator from
3. Write a small math game according to the following requirements. (updated version of in-class practice 01/30/2019) 1) Ask user to choose one operator from +, -, *, /. if the operator is not one of +, -, *, /, ask user to choose again 2) Ask user to input two different integer numbers. If one of the numbers is <0, ask user to input again. If both numbers are the same, ask user to input again. 3) Assign smaller number to lower bound of random number. 4) Assign bigger number to upper bounder of random umber. eg, if first number = 30, second number = 10, then lb=10, ub=30 eg, if first number = 10, second number = 30, then lb=10, ub=30 5) Generate two random numbers using the lower bound and upper bound. 6) Display Math formula using the numbers and the operator. (eg: 13 * 25 = ? ) to calculate the answer, create a method like public static int math(String op, int a, int b) { int result; .. return result; } you must pass 3 parameters to the method and receive a result from the method. (Assume all the numbers are integer) 7) Ask user to answer 8) If the users answer is incorrect. go to 7) if user input wrong answer 3 times, print message study more!, then go to 10) 9) If the users answer is correct, go to 10) 10) Ask user to play again or not. If user input is Y or y, then go to 1) If user input is N or n, then terminate this game with good bye! message.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
