Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

TheMathGame: Your task is to develop a program that will teach youngsters the basic math facts of addition, subtraction, multiplication and division. The program generates

TheMathGame:

Your task is to develop a program that will teach youngsters the basic math facts of addition, subtraction, multiplication and division. The program generates random math problems for students to answer. Players get a small reward for correct answers and suffer a small penalty for incorrect ones. User statistics need to be recorded in a text file so that they me loaded back into the program when the player returns to play the game again. In addition, the youngster should be allowed to see how (s)he is doing at any time while (s)he is playing the game.

WARNING:

Note that your main() function should consist of mostly function calls and not be greater than 100 lines in total; however, your entire program will be closer to 500 - 800 lines of code!

PROGRAM REQUIREMENTS

Generate simple math fact problems:

Addition (the total must be an integer >= 0)

Subtraction (the difference must be an integer >= 0)

Multiplication (the product must be an integer >= 0)

Division (the quotient must be an integer >= 0)

Validate user input at every opportunity. If your program crashes because you allow the user to make an invalid entry and you did not write code to handle such potential exceptions, you will NOT pass the midterm!

The program should keep track of the following statistics:

The users name

The total correct answers

The total wrong answers

The total earnings ($0.05 is awarded for every correct response and $0.03 is subtracted from every incorrect response)

A separate text file must be created for every user:

Statistics are read from the file at the start of the game (if the user is a returning player).

Statistics are recorded at the end of every game.

The program must be developed using functions so that the main() function consists mostly of function calls. Below is a list of most of the required functions, you may add your own functions if you like:

credits //This function is used to display your name and what the program does

menu // This function is used to display the menu with various options

validateUserResponse // This function is used to validate user input from the menu

validateUserAnswer // This function is used to validate user input and ensure that ONLY numeric answers are entered by the user.

checkUserAnswer // given a math problem, this function is used to check if the answer the user entered is correct or incorrect

updateStats // This function is used to keep a running total of game statistics (in RAM)

displayStats // This function is used to display statistics on screen

retireveStats // This function is used to retrieve player statistics from external txt file when the game starts, assuming the player is a returning player, else create a text file to store the stats.

saveStats // This function is used to save player statistics on an external txt file.

You may also want to consider the following four functions: generateAddition, generateSubtraction, generateMultiplication and generateDivision // use these to generate a problem of the appropriate type.

You must use meaningful variable names.

You must comment your code.

You must use variables of the correct type and initialize them with a proper value.

GENERAL RESTRICTIONS

No infinite loops, examples include:

for(;;)

while(1)

while(true)

do{//code}while(1);

No break statements to exit loops

No labels or go-to statements

image text in transcribed

image text in transcribed

Program Flow 1. At the start of the game, an initial "Splash screen must be displayed which includes: a. The game's title b. Your name TheHathGane By Prof. * Flores yto continue, any other char to exit After the "Splash screen a prompt must ask the user for his/her name (validate input: no numbers, no blanks Enter your nane and press KENTER> 2. Once you have the user's name, display a menu with the options listed in the graphic below (validate input only options 1, 2, 3, 4, 5, n and N must be allowed): HOOSE A PROBLEMMMN 1. ADD 2. SUBIRACT 3. HULTIPLY 4. DIUIDE 5. STATS nN to QUIT 3. If the user chooses option 1 or 2 or 3 or 4 arandomly generated problem isdisplay ed (validate input: only positive integers must be allowed): 6-3? Program Flow 1. At the start of the game, an initial "Splash screen must be displayed which includes: a. The game's title b. Your name TheHathGane By Prof. * Flores yto continue, any other char to exit After the "Splash screen a prompt must ask the user for his/her name (validate input: no numbers, no blanks Enter your nane and press KENTER> 2. Once you have the user's name, display a menu with the options listed in the graphic below (validate input only options 1, 2, 3, 4, 5, n and N must be allowed): HOOSE A PROBLEMMMN 1. ADD 2. SUBIRACT 3. HULTIPLY 4. DIUIDE 5. STATS nN to QUIT 3. If the user chooses option 1 or 2 or 3 or 4 arandomly generated problem isdisplay ed (validate input: only positive integers must be allowed): 6-3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions

Question

=+j Understand different types of regions in the world.

Answered: 1 week ago