You are required to design and implement a maths test


You are required to design and implement a "Maths Test" program that generates simple maths questions, presents them one at a time to the user, and prompts them to enter the answer. The program determines whether the answer is correct and keeps track of data in order to present statistics and a grade to the user once a certain number of questions have been answered.

Despite the similar sounding theme, this program has very little in common with the case study in

Module 5. The case study program involved generating tests to be printed, while this assignment requires an interactive program that administers the test - prompting the user for an answer to each question it generates.

Implement all of the following requirements, and ask your tutor if you do not understand any of the requirements or would like further information. The requirements of the program are:

1. The program should welcome the user and prompt them to choose Easy, Medium or Hard:2. Re-prompt the user until a valid response (1, 2 or 3) is entered. Once a difficulty has been chosen, print a message to confirm the selected difficulty and set variables as follows:

  •  If "Easy" was chosen... lives = 3 and maxNum = 10
  •  If "Medium" was chosen... lives = 2 and maxNum = 25
  •  If "Hard" was chosen... lives = 1 and maxNum = 50

The lives variable determines how many questions the user can get wrong before the test ends, and the maxNum variable determines the biggest number that can be generated in a question. 3. The program should then enter a loop that will be used to ask 10 questions. The loop body code must generate and display a question, prompt for and check the answer, and display feedback:

3.1. Write a function named "generateQuestion" which requires a parameter of the maxNum variable. The function should generate two random numbers between 1 and maxNum, and then randomly choose between the addition ("+") or subtraction ("-") operator. Concatenate the numbers and operator into a string (e.g. "What is 20 + 25?") and also calculate the answer to the question (e.g. 45). The function should return both the question string and the answer (an integer).

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: You are required to design and implement a maths test
Reference No:- TGS01244041

Expected delivery within 24 Hours