Question

Write a MIPS math quiz program in MARS. The program should start with a friendly user...

Write a MIPS math quiz program in MARS.

The program should start with a friendly user greeting.

From there, it should generate a random arithmetic problem.

Your program will need to generate three random things: the first and second operand and the operator to use.

Your program should generate random positive integers no greater than 20 for the operands.

The possible operators are +, -, * and / (division).

The user should be prompted for an answer to the problem.

If they are correct or incorrect, the program should inform them either way.

Continue prompting the user to solve addition problems until they enter a value of -1.

If they enter -1, print out their score (how many problems they solved correctly/incorrectly, along with a percentage of how many were correct).

Then quit the program.

Here’s a sample run of the program (user input is bold):

Hello, welcome to MathQuiz, here is your first problem:

What is 3 + 14? 17

Correct!

What is 8 – 5? 4

Incorrect!

What is 10 + 10? -1

You solved 2 math problems and got 1 correct and 1 incorrect, for a score of 50%.

Thanks for playing!

(exit)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

name = input("What is your name? ")
print("Hello, "+name+". You will be completing a quiz that will ask you 10 questions which will test you on adding, subtracting and multiplying two numbers together. Try your best at each question and good luck!")

import random
from operator import add, sub, mul

count = 0
score = 0
while count <= 9:
ops = (add, sub, mul)
op = random.choice(ops)
x = random.randint(1,10)
y = random.randint(1,10)

if op == add:
print("What is", x, "+",y, "? ")
question_add = int(input())
answer_add = op(x,y)
if question_add == answer_add:
print("Well done, this is correct!")
score = score + 1
count = count + 1
else:
print("Sorry, but this is incorrect.")
count = count + 1

elif op == sub:
print("What is", x, "-", y, "? ")
question_sub = int(input())
answer_sub = op(x,y)
if question_sub == answer_sub:
print("Well done, this is correct!")
score = score + 1
count = count + 1
else:
print("Sorry, but this is incorrect.")
count = count + 1

elif op == mul:
print("What is", x, "x", y, "? ")
question_mul = int(input())
answer_mul = op(x,y)
if question_mul == answer_mul:
print("Well done, this is correct!")
score = score + 1
count = count + 1
  
else:
print("Sorry, but this is incorrect.")
count = count + 1

if count == 10:
print("Well done "+name+"! You have completed the quiz. Your final score out of 10 is "+str(score)+".")

Add a comment
Know the answer?
Add Answer to:
Write a MIPS math quiz program in MARS. The program should start with a friendly user...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Math Problem Generator Your job will be to write a C++ program to teach math to...

    Math Problem Generator Your job will be to write a C++ program to teach math to school children. Your program will accomplish this by showing sets of math problems to the user and allowing them to enter an answer. The program should tell the user if they are correct and should continue providing additional questions. The program will keep track of correct and incorrect answers. The questions should use random numbers and should be simple enough math problems that someone...

  • Instructions Basically, you will modify the mathq program to make it satisfy a different set of...

    Instructions Basically, you will modify the mathq program to make it satisfy a different set of requirements, and fix what is not working in it. Specifically, imagine that the client for whom we created the mathq program for would now like some changes. To be exact: Part 1: They want it to provide addition and subtraction problems as well as multiplication and division. They still want the choice to be random, as before, but now the problem is randomly multiplication,...

  • This program is to ask the user N number of math (using only +, -, *,...

    This program is to ask the user N number of math (using only +, -, *, and /) questions. Once the program start it asks the user to enter how many questions will be asked (N, which is between 3-10). Then, the program asks N questions to the user. Each question will be one of four math operations (+, -, *, and /). The operation and operands will be selected randomly in your program.Operand are “unsigned short” between 0 and...

  • In phyton 11. Math Quiz Write a program that gives simple math quizzes. The program should...

    In phyton 11. Math Quiz Write 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 should allow the student to enter the answer. If the answer is correct, a mes- sage of congratulations should be displayed. If the answer is incorrect, a message showing the correct answer should be displayed

  • Write a program which gives an easy mathematics quiz. The program should display two random numbers...

    Write a program which gives an easy mathematics quiz. The program should display two random numbers which are to be added together, like this: 117 + 213 ----- The program should ask the user to enter their answer. If the answer is correct, the user should be congratulated. If the answer is wrong, the right answer should be displayed and the user should be scolded. Don't forget to: Generate random numbers Ask the user if they want to be tested...

  • Need a program in java that creates a random addition math quiz The program should ask...

    Need a program in java that creates a random addition math quiz The program should ask the user to enter the following The smallest and largest positive numbers to be used when generating the questions - The total number of questions to be generated per quiz - The total number of the quiz's to create from then the program should generate a random math (Just addition) quiz from what the user entered

  • Using Java IDE: Write an application that asks elementary students a set of 10 math problems...

    Using Java IDE: Write an application that asks elementary students a set of 10 math problems ● First ask the user for a level and a problem type. ● You need to validate the level and problem type and loop until the user enters a correct one. ● There should be 3 levels. Level 1 operands would have values in the range of 0-9, level 2 operands would have values in the range of 0-99, and level 3 operands would...

  • Task 3 [35 marks] Write a MIPS program that does the following (in a correct, user-friendly...

    Task 3 [35 marks] Write a MIPS program that does the following (in a correct, user-friendly way):  Greets the user, states the purpose of the program  Sequentially asks the user to provide integer coefficients A,B,C  Calculates discriminant D of quadratic polynomial. (Hint: D = B2 – 4×A×C)  Displays the calculated D value  Checks (in this order) whether discriminant is: o D = 0? Then, displays: “Quadratic polynomial has a sole root.” o D > 0?...

  • USING C LANGUAGE _Design_ a program that asks the user to answer (easy) multiplication problems. It...

    USING C LANGUAGE _Design_ a program that asks the user to answer (easy) multiplication problems. It is up to you how many math problems you want it to present. The numbers should be chosen at random. The program will then display the user stats: - number of problems answered correctly out of the total - percent correct - grade letter (>= 90 is A, >= 80 is B, >= 70 is C, >=60 is D, < 60 is F)   Example...

  • (For Python program)   Write a program that fulfills the functionalities of a mathematical quiz with the...

    (For Python program)   Write a program that fulfills the functionalities of a mathematical quiz with the four basic arithmetic operations, i.e., addition, subtraction, multiplication and integer division. A sample partial output of the math quiz program is shown below. The user can select the type of math operations that he/she would like to proceed with. Once a choice (i.e., menu option index) is entered, the program generates a question and asks the user for an answer. A sample partial output...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT