i tried to run this program but it comes up with the windows 6th grade algebra quiz has encuontered a problem and has to close message can
anyone help?
here is the code:
#include <fstream>
#include <cstdlib>
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <string>
#include <conio.h>
using namespace std;
int report();
int falseReport();
int nointros = 1;
int noquestionswanted = 0;
int grade = 0;
int noguesses = 0;
int noCorrect = 0;
int nowrong = 0;
int guess = 0;
int X = 0;
int a = 0;
int b = 0;
int X2 = 0;
int a2 = 0;
int b2 = 0;
int problem = 0;
double area = 0;
int R = 0;
int lob = 0;
int heighth = 0;
int R2 = 0;
int area2 = 0;
int nothing = 0;
int main()
{
if(noguesses == noquestionswanted )
{
report();
}
if(nointros == 1)
{
cout<<"hi this is the pre-algabra quiz"<<endl;
cout<<"if you are taking this you will need a pencil and paper";
cout<<"once you have done that press any number and enter to continue";
cin>>nothing;
cout<<"how many questions would you like"<<endl;
cout<<"1. 10"<<endl;
cout<<"2. 15"<<endl;
cout<<"3. 20"<<endl;
cin>>noquestionswanted;
nointros++;
if(noquestionswanted == 1)
{
noquestionswanted = 10;
}
else if(noquestionswanted == 2)
{
noquestionswanted = 15;
}
else if(noquestionswanted == 3)
{
noquestionswanted = 20;
}
else if(noquestionswanted == 999)
{
falseReport();
return 0;
}
else
{
cout<<"I'm sorry that is not a choice please type 1, 2, or 3 next time"<<endl;
main();
}
cout<<"press any number and enter to begin";
}
else
{
cout<<"press any number and enter to continue";
}
cin>>nothing;
srand((unsigned)time(NULL));
problem = 1 + rand() % 5;
if(problem == 1)
{
srand((unsigned)time(NULL));
b = 1 + rand() % 100;
srand((unsigned)time(NULL));
a = 1 + rand() % 100;
X = b - a;
cout<<"solve this equasion"<<endl;
cout<<"a+x=b if a="<<a<<endl;
cout<<"and b="<<b<<endl;
cin>>guess;
if(guess == X)
{
cout<<"correct!";
noCorrect++;
noguesses++;
}
else
{
cout<<"I'm sorry but you got it wrong the corect answer is:"<<endl;
cout<<X<<endl;
nowrong++;
noguesses++;
}
main();
return 0;
}
else if(problem == 2)
{
srand((unsigned)time(NULL));
b2 = 1 + rand() % 100;
srand((unsigned)time(NULL));
a2 = 1 + rand() % 100;
X2 = a2 - b2;
if(guess == X)
{
cout<<"correct!"<<endl;
noCorrect++;
noguesses++;
}
else
{
cout<<"I'm sorry but you got it wrong the corect answer is:"<<endl;
cout<<X2<<endl;
nowrong++;
noguesses++;
}
main();
return 0;
}
else if(problem == 3)
{
srand((unsigned)time(NULL));
R = 1 + rand() % 100;
cin>>R;
R2 = R *= R;
area = 3.1415926 * R2;
if(guess == area)
{
cout<<"correct!"<<endl;
noCorrect++;
noguesses++;
}
else
{
cout<<"I'm sorry but you got it wrong the corect answer is:"<<endl;
cout<<X2<<endl;
nowrong++;
noguesses++;
}
main();
return 0;
}
else if(problem == 4)
{
srand((unsigned)time(NULL));
heighth = 1 + rand() % 100;
srand((unsigned)time(NULL));
lob = 1 + rand() % 100;
area2 = heighth*lob/2;
cout<<"what is the area of a triangle with a height"<<endl;
cout<<"of "<<heighth<<"and a base length of "<<lob<<"?"<<endl;
cin>>guess;
if(guess == area2)
{
cout<<"correct!"<<endl;
noCorrect++;
noguesses++;
}
else
{
cout<<"I'm sorry but you got it wrong the corect answer is:"<<endl;
cout<<X<<endl;
nowrong++;
noguesses++;
}
main();
return 0;
}
else if(problem == 5)
{
srand((unsigned)time(NULL));
heighth = 1 + rand() % 100;
srand((unsigned)time(NULL));
lob = 1 + rand() % 100;
area2 = heighth*lob/2;
cout<<"what is the area of a square or rectangle with a height"<<endl;
cout<<"of "<<heighth<<"and a base length of "<<lob<<"?"<<endl;
cin>>guess;
if(guess == area)
{
cout<<"correct!"<<endl;
noCorrect++;
noguesses++;
}
else
{
cout<<"I'm sorry but you got it wrong the corect answer is:"<<endl;
cout<<X<<endl;
nowrong++;
noguesses++;
}
main();
return 0;
}
else
{
cout<<"please choose 1, 2, 3, 4, or 5"<<endl;
main();
return 0;
}
return 0;
}
report()
{
grade = noCorrect / noguesses * 100;
cout<<"your final report for the "<<noguesses<<" qustions you answered are as followed"<<endl;
cout<<"you got "<<noCorrect<<"correct and "<<nowrong<<" wrong "<<endl;
cout<<"your grade is a "<<grade<<" percent"<<endl;
cout<<"the program is over";
return 0;
}
falseReport()
{
cout<<"your final report for the 20 qustions you answered are as followed"<<endl;
cout<<"you got 20 correct and 0 wrong"<<endl;
cout<<"the program is over";
return 0;
}