Question
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.
This is the code I have so far. The additions need to be made inside of this code please. I cannot figure out how to incorporate what she is asking into the code I already have. thanks in advance.
#include
#include
#include
int Menu();
int Addition();
int Subtraction();
int Multiplication();
int Division(int x, int y);
main()
{ int option;
//srand(time(NULL));
option = Menu();
while(option != 5)
{
//switch(option)
//{ case 1:Addition();break;
//case 2:Subtraction();break;
//case 3:Multiplication();break;
//case 4:Division();break;
}
option = Menu();
//}
}
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);
int Add;
int Division();
return 0;
}
int Add()
{
int correctAnswer;
printf("35 + 15 = ?");
scanf("%d", &correctAnswer);
if (correctAnswer==50)
printf("Correct!");
else
printf("Incorrect.");
return 0;
}
int Addition(int x,int y){
return x+y;
}
int Subtraction(int x,int y){
return x-y;
}
int Multiplication(int x,int y){
return x*y;
}
//pair
//int Divison(int x,int y)
//{
//int quotient=max(x,y)/min(x,y);
//int remainder=max(x,y)%min(x,y);
//return {quotient,remainder};
//}
int Division (int num1, int num2)
{
int remainder, remainder1, answer, answer1;
printf (" %d/ %d = ?... ", num1, num2); //output division
printf ("Enter answer:");
scanf ("%d", &answer);
printf ("Enter remainder:");
scanf ("%d", &remainder);
answer1 = num1 / num2; //calculate division
remainder1 = num1 % num2; //calculate remainder
if (answer == answer1 && remainder == remainder1) { //if your answer equals calculation
printf (" Correct! "); //output answer correct
}
else if (answer >= 1) {
printf (" Incorrect :( "); //output answer incorrect
} //end if
else {
printf ("Sorry...try again with a different answer. ");
} //end if
return 0;
} //division function end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started