Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a program that gives simple math quizzes. The program should display two

ID: 642842 • Letter: D

Question

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

Explanation / Answer

import random from sys import exit add1 = random.randint(1, 10) add2 = random.randint(1, 10) answer = str(add1 + add2) question = "What is %d + %d?" % (add1, add2) print question print answer userIn = raw_input("> ") if userIn.isdigit() == False: print "Type a number!" #then I want it to ask the same question and prompt for an answer. elif userIn == answer: print "AWESOME" else: print "Sorry, that's incorrect!" print "Play again? y/n" again = raw_input("> ") if again == "y": pass #play the game again else: exit(0)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote