Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this project, you will create a program that will test the users proficiency at solving different types of math problems. The program will be

For this project, you will create a program that will test the users proficiency at solving different types of math problems. The program will be menu driven. The user will select either addition, subtraction, multiplication or division problems. The program will then display a problem, prompt the user for an answer and then check the answer displaying an appropriate message to the user whether their answer was correct or incorrect. The user will be allowed 3 tries at each problem. The program will also keep statistics on how many problems were answered correctly.

At this point you should have a working copy of the program that displays practice programs for addition, subtraction, multiplication and division.

This week you will add functions to allow the user to select problems of varying degrees of difficulty and also keep statistics on number of correct answers vs. total number of problems attempted.

So now lets add the code for the remaining functions:

Well start by inserting code to ask the user if they want to see problems that are easy, medium or difficult. Well do this by prompting them to enter e for easy, m for medium or d for difficult and well do this right after they have selected the type of problems they want. We will also add a validation loop that will check to see if they entered a correct response (e,m, or d).

Easy problems using numbers 0 thru 10

Medium problems 11 thru 100

Difficult problems 100 1000

Heres some code to get you started on the difficulty level.

if( difficultyLevel == 'E')

{

num1=rand()%10+1;

num2=rand()%10+1;

}

else

if (difficultyLevel == 'M')

{num1=rand()%100+1;

num2=rand()%100+1;

}

else

{ num1=rand()%1000+1;

num2=rand()%1000+1;}

Use an if statement to check the difficulty and generate the random numbers.

Statistics:

Create two variables ttlProblems and correctAnswers. Every time the user answers a problem add 1 to ttlProblems and every correct answer add 1 to correctAnswers. Well display the total number of problems and correct answers as well as the percent correct after the user has selected the exit option on the main menu.

I NEED TO INCORPORATE WHAT THIS ASSIGNMENT IS ASKING ME INTO MY CURRENT CODE. HOW WOULD I DO THAT?

#include #include #include

int Menu(); float Addition(float, float); float Subtraction(float, float); float Multiplication(float, float); float Division(float, float, float *);

void additionTest(float, float); void subtracttionTest(float, float); void multiplicationTest(float, float); void divisionTest(float, float);

int main()

{ int option, quit = 0; float num1, num2; srand(time(0));

while (!quit) { option = Menu(); // generate two floating point randum numbers in range 0 to 10000 num1 = ((float)rand()/(float)(RAND_MAX)) * 10000; num2 = ((float)rand()/(float)(RAND_MAX)) * 10000; switch (option) { case 1: additionTest(num1, num2);

break;

case 2: subtracttionTest(num1, num2); break;

case 3: multiplicationTest(num1, num2); break;

case 4: if (num1 > num2) { divisionTest(num1, num2); } else { divisionTest(num2, num1); } break;

case 5: quit = 1; break; } } }

int Menu()

{ int option; puts("Math Practice Program"); puts("1. Addition"); puts("2. Subtraction"); puts("3. Multiplication"); puts("4. Division"); puts("5. Quit"); printf("Enter an option "); scanf("%d", &option); return option; }

void additionTest(float num1, float num2) { float answer,correctAnswer; printf("What is %f + %f = ? ==> ", num1, num2); scanf("%f", &answer); correctAnswer = Addition(num1, num2); if (correctAnswer == answer) { printf("Correct Answer "); } else { printf("Wrong Answer "); printf("Correct answer is : %f ",correctAnswer); } } void subtracttionTest(float num1, float num2) { float answer,correctAnswer; printf("What is %f - %f = ? ==> ", num1, num2); scanf("%f", &answer); correctAnswer = Subtraction(num1, num2); if (correctAnswer == answer) { printf("Correct Answer "); } else { printf("Wrong Answer "); printf("Correct answer is : %f ",correctAnswer); } }

void multiplicationTest(float num1, float num2) { float answer,correctAnswer; printf("What is %f * %f = ? ==> ", num1, num2); scanf("%f", &answer); correctAnswer = Multiplication(num1, num2); if (correctAnswer == answer) { printf("Correct Answer "); } else { printf("Wrong Answer "); printf("Correct answer is : %f ",correctAnswer); } }

void divisionTest(float num1, float num2) { float answer,correctAnswer, remainder,rem; printf("What is %f / %f = ? ==> ", num1, num2); printf(" Enter answer: "); scanf("%f", &answer); printf("Enter remainder: "); scanf("%f", &remainder); correctAnswer = Division(num1, num2, &rem); if (correctAnswer == answer && rem == remainder) { printf("Correct Answer "); } else { printf("Wrong Answer "); printf("Correct answer is : %f ",correctAnswer); printf("Correct remainder is : %f ",rem); } }

float Addition(float num1, float num2) { return num1 + num2; }

float Subtraction(float num1, float num2) {

return num1 - num2; }

float Multiplication(float num1, float num2) {

return num1 * num2;

}

float Division(float num1, float num2, float * remainder) {

*remainder=(int)num1%(int)num2; return num1/num2;

}

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

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

Have you laid out a timeframe for refreshing the data regularly?

Answered: 1 week ago

Question

Have you laid out the information as clearly as possible?

Answered: 1 week ago

Question

Have you tested your findings with those closest to the market?

Answered: 1 week ago