OK here is the problem. I made a program for school that would give a simple math test. Easy enough. Well what is happening is that I got two random numbers coming up in the division part and that is working great, but the total is per say 1.7898654 . ok thats ok also but when I go to answer the math problem if I put in 1.7898654 then its wrong and the answer display is 1.78987. then if i answer it 1.78987 then it will be 1.7899. I am lost. I am trying to do something like this.
1 2
total = rand1 / rand2;
total = setprecision(2);
but am getting this error: 1>.\MathTest.cpp(157) : error C2440: '=' : cannot convert from 'std::_Smanip<_Arg>' to 'double'
cout << "\n\nNow division questions: " << endl;
cout << "Remember you have to get 10 questions correct to move on." << endl;
int z = 1;
while(cor4 < 3)
{
rand1 = (rand()%100);
rand2 = (rand()%10);
cout << "\nQuestion # " << z << ":" << " \nWhat do " << rand1 << " / " << rand2 << " equal? " << endl;
cin >> answer;
total = rand1 / rand2;
total = setprecision(2);
if(total == answer)
{
cout << "Correct! " << endl;
cor4 = cor4 += 1;
}
else
{
cout << "Wrong! " << endl;
cout << "The correct answer was " << total << endl;
wor = wor += 1;
}
z = ++z;
Now that is the whole code for the multiplication part if anyone has any help. I just knew for sure the setprecision would work but its apparently only for times like