Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Write in C++ 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. Students 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 student 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. One of the MAJOR objectives of this assessment is for you to demonstrate your ability to use functions and employ reference and value parameters.

WARNING:

Do not employ functions which use reference and value parameters

You should also 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, just remember that If you do not employ functions which use reference and value parameters you will NOT pass the midterm:

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.

All functions must be correctly prototyped.

All functions must be correctly defined.

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 FOR ALL QUIZZES, MIDTERM AND FINAL EXAM

No global variables

No infinite loops, examples include:

for(;;)

while(1)

while(true)

do{//code}while(1);

No break statements to exit loops

SPECIFIC RESTRICTIONS FOR THIS ACTIVITY

See above

image text in transcribed

image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

Describe the main stages of a debtor-based revenue cycle.

Answered: 1 week ago

Question

LO3 Define the difference between job satisfaction and engagement.

Answered: 1 week ago