Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The principal of the local school would like you to create a C++ program that th

ID: 3714589 • Letter: T

Question

The principal of the local school would like you to create a C++ program that the first and second graders can use to practice their addition and subtraction.

The program should have two levels that can be selected, Level 1 should include numbers 1 to 10 only and Level 2 should include numbers 1 to 100. The user should also select either addition or subtraction. Create a menu that the user can select the level (either Level 1 or Level 2) and operation (either addition or subtraction). The larger number should always be first so the student will not get confused if subtracting.

Random numbers should be used for the program. Use a function to generate the random numbers and any other functions that you may chose. There should be a minimum of two functions.

The user should enter a filename, name and date. Next the menu for the level and operation should appear and the student should select the level and operations. Two accumulators should be used, one for correct answers and one for incorrect answers. The user should continue with the operation until or she enters a -1 to exit.

The user should be told whether he/she was correct and should have as many tries as necessary to get the correct answer. They should also be told how many were correct and how many were wrong after they answer . It should then generate another problems for him/her to do.

When the user exits the program, the program should write to the file their Name, Date, Total Correct and Total Incorrect and then close the file.

Take your time creating this project. Please do not wait until the last minute to start to work on it. This project is more complicated than the exercises we do after each chapter. If you need help, please let me know and I will be glad to steer you in the right direction.

Your project should be clear and easy to read. Appropriate controls with clean code and comments and remarks should be used. Programming logic should flow logically, should be broken down into small steps, use comparisons (if applicable) , If/Else (if applicable), and be all encompassing.

Programming methods should use two functions and use variables, and any other programming methods that you consider necessary. Make sure that the design is appropriate, that the procedures are working correctly, that the program is cohesive and comprehensive.

Explanation / Answer

#include<iostream>

#include<cstdlib>

#include<fstream>

using namespace std;

int main()

{

char filename[50],name[50],date[12];

int option,ans,uans,lower,upper,a,b,level,opt,correct=0,incorrect=0;

cout<<"Enter File Name : ";

cin>>filename;

cout<<" Enter Your First Name : ";

cin>>name;

cout<<" Enter Date (DD/MM/YYYY) : ";

cin>>date;

while(option!=-1)

{

cout<<" Enter 1 for Level 1. Enter 2 for Level 2. Select Level : ";

cin>>level;

cout<<" Enter 1 for addition . Enter 2 for subtarction . Select opration : ";

cin>>opt;

if((level==1 || level ==2) && (opt==1 || opt==2))

{

lower=1;

if(level==1)

upper=10;

else

upper=100;

/* Generate random number */   

a=(rand() %(upper - lower + 1)) + lower;

b=(rand() %(upper - lower + 1)) + lower;

if(opt==1)

{

ans=a+b;

cout<<a<<" + "<<b<<" = ";

/*perform operation */

}

else

{

ans=(a>b ? a-b : b-a);

a>b ? (cout<<a<<" - "<<b<<" = ") : (cout<<b<<" - "<<a<< " = ");

}

cin>>uans;

if (ans==uans )

{

correct ++;

cout <<" Correct Answer ";}

else

{

incorrect ++; cout << " Incorrect Answer ";

}

}

else

{

cout<<"Incorrect option !";

}

cout << " Enter -1 to exit : ";

cin>>option;

}

cout<<" Dear "<<name <<" ! Total Correct Answer : "<<correct<<" Total Incorrect Answer : "<<incorrect;

/* open file name Entered by user to write Report*/

ofstream outfile;

outfile.open(filename);

/* write to file */

outfile<<"Dear "<<name <<" ! "<<date <<" Total Correct Answer : "<<correct<<" Total Incorrect Answer : "<<incorrect;

  

/* close opened file */

outfile.close();

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote