Home / Expert Answers / Computer Science / question-1-4-mark-implement-a-program-which-helps-the-user-to-do-some-addition-exercises-requir-pa132

(Solved): Question 1 (4 mark) : Implement a program which helps the user to do some addition exercises. REQUIR ...



Question 1 (4 mark) : Implement a program which helps the user to do some addition exercises.

REQUIREMENTS
• The user input is always correct (input verification is not required).
• Your code must use do-while loop.
• In the main method, three random numbers [20,50] are generated as the operands of the addition, the program will check whether the answer is correct or not and displays corresponding information. It then asks the user to continue the exercise or not and reads the entered string. Each time when finishing the exercise, the number of questions asked, the number of correct answers, and the accuracy will be displayed.
• The accuracy shall be displayed with one decimal point precision.
• Your code must work as the following example (the text in bold indicates the user input).

Example of the program output:
Example 1:
44 + 25 + 31 = 100
Correct!
Will you continue addition exercises (Yes/No): No
The number of questions you have answered is 1 (1 correct), your accuracy is: 100.0%

Example 2:
22 + 43 + 30 = 77
Wrong! The correct answer is 95.
Will you continue addition exercises (Yes/No): Yes
49 + 28 + 22 = 12
Wrong! The correct answer is 99.
Will you continue addition exercises (Yes/No): Yes
34 + 40 + 34 = 108
Correct!
Will you continue addition exercises (Yes/No): No
The number of questions you have answered is 3 (1 correct), your accuracy is: 33.3%

Code must be in JAVA



We have an Answer from Expert

View Expert Answer

Expert Answer


Part 1 import java.lang.Math; import java.util.Scan; HelloWorld class { public static void main (String [] args) { Scan sc = New scanner (System.in); int cont = 1; int min = 20; int max = 50; int post = 0, total = 0; int neg = 0; do { value = value +
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe