Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This project is written in five parts. One part is due each week of the course. Click the gray box below the instructions to load

This project is written in five parts. One part is due each week of the course. Click the gray box below the instructions to load the submission inbox for the final part of the project.

There is an executable file, MathPractice.exe, which shows a completed version of the program. Your campus computers should have sufficient supporting files to run MathPractice.exe, but, if not, weve provided screen shots of each stage.

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.

This week youll complete your project. First, check through for any corrections you need to make perhaps your instructor as comments from Unit 4 that you want to incorporate.

Then, alter the code to allow for floating point numbers. This requires formatting the output.

Upload your .c file, and a screen shot of your code output saved in a Word document including the path name directory at the top of the screen into the dropbox for grading.

I NEED HELP ALTERING TO ALLOW FOR FLOATING POINT NUMBERS

#include #include #include

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

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

int main()

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

while (!quit) { option = Menu(); // generate two randum numbers in range 0 to 10000 num1 = rand() % (10000 + 1) + 1; num2 = rand() % (10000 + 1) + 1; 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(int num1, int num2) { int answer,correctAnswer; printf("What is %d + %d = ? ==> ", num1, num2); scanf("%d", &answer); correctAnswer = Addition(num1, num2); if (correctAnswer == answer) { printf("Correct Answer "); } else { printf("Wrong Answer "); printf("Correct answer is : %d ",correctAnswer); } } void subtracttionTest(int num1, int num2) { int answer,correctAnswer; printf("What is %d - %d = ? ==> ", num1, num2); scanf("%d", &answer); correctAnswer = Subtraction(num1, num2); if (correctAnswer == answer) { printf("Correct Answer "); } else { printf("Wrong Answer "); printf("Correct answer is : %d ",correctAnswer); } }

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

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

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

int Subtraction(int num1, int num2) {

return num1 - num2; }

int Multiplication(int num1, int num2) {

return num1 * num2;

}

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

*remainder=num1%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

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions

Question

Question Can I collect benefits if I become disabled?

Answered: 1 week ago

Question

Question May I set up a Keogh plan in addition to an IRA?

Answered: 1 week ago