The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 1 Day Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Design a program that gives simple math quizzes. The program should display two random numbers that are to be added, such as
247
+ 129
The program (Java language) should allow the student to enter the answer. If the answer is correct, a message of congratulations should be displayed. If the answer is incorrect, a message showing the correct answer should be displayed
Here is the pseudo-code to follow
//Declare the variables to hold intermediate and final values
Declare Integer rand1, rand2, sum ans
//Get the random numbers generated by the function
//random and assign those values in rand1 and rand2 respectively
Set rand1 = random(1, 999)
Set rand2 = random(1, 999)
//Dsiplay rand1 and rand2 in a formatted way treated for addition
Display A????1 A????1, rand1
Display A????1+ A????1,rand2
//Read the result of addition inputted by the student and put it in ans
Display A????1Please enter your answer.A????1
Input ans
//Calculate the sum of random numbers and put it to sum
Set sum = rand1 + rand2
//Determine whether ans and sum are same. If same display a congratulation message, or else display a failure message and show the correct
If ans == sum Then
           Display A????1Congratulations!!! Your answer is correct.A????1
Else
           Display A????1Sorry!!! Your answer is wrong.A????1
           Dis play A????1Correct answer is A????1, sum, A????1.A????1
End if
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll