Question: Write a Java program to help first graders to practice math subtraction. Your program must:randomly generate two single-digit integers, number1 and number2 . number1 must
Write a Java program to help first graders to practice math subtraction.
Your program must:randomly generate two single-digit integers, number1 and number2.
number1 must be greater than or equals to number2 (i.e., number1 number2)
If number1 < number2, swap number1 with number2
ask the student the question: What is number1 - number2?
verify the students answer, and display whether the answer is correct:
You are correct!, if the answer is correct.
Your answer is incorrect. number1 - number2 is difference, if the answer is incorrect.
Where difference is the result of number1 minus number2
ask the student the question: Do you want to play again?
If y or Y, the program loops back to the begin.
If n or N, the program exits
The following represents two sample test cases of the program. You are required to generate the user interface (UI) as shown below.
User entered correct answer (1)
What is 4 - 3? 1
You are correct.
Do you want to play again? (Y/N) Y
User entered incorrect answer (6)
What is 8 - 3? 6
Your answer is incorrect. 8 - 3 is 5
Do you want to play again? (Y/N) N
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
