What the program should do:
The program should allow the user to specify a range of values for a times tables test. The bottom end of the range for test purposes is 0 and the top end of the range should be at most 10(again for test). The user specified range is valid (ie the bottom end of the range is not larger than the top end of the range).
Each time a question is answered incorrectly, the program should display the correct answer.
Upon completing the times tables test, the program should tell the user how many questions were missed and the percentage of the questions that were answered correctly.
My problems or questions:
1st problem:
I am having problems with my "top" and "bottom" range maybe i'm going about doing it the wrong way.
2nd problem:
my percentage is not working correctly. the correct and total is okay, but its probably in the way i structured my formula.
I'm still VERY new at all this. Any help is appreciated.
My Code:
#include<iostream>
using std::cout;
using std::cin;
int main()
{
int a,b,c, bottom, top;
int guess, correct=0, total=0;
float worth=0, percentage=0;
cout<< "Enter the bottom end of the range (from 0 to 10): ";
cin >> bottom;
cout<< "\nEnter the top end of the range (from 0 to 10): ";
cin >> top;
bottom=(a&&b);
top=c;
for (int a=bottom; a<=c; a++)
{
for (int b=bottom; b<=c; b++)
{
cout << "\n\nWhat is ? " << a << " * " << b << " = : ";
cin >> guess;
if (guess==a*b)
{
cout << " \n\ncorrect \n\n";
++correct;
}
else
cout << " \n\nSorry, the correct answer is "<<a<<" * "<<b<<
<< " = "<<a*b<<"\n\n";
++ total;
}
}
worth=100/total;
percentage=(worth*correct);
cout << "You answered " << total << " questions in total.\n\n";
cout << correct <<" were answered correctly.\n\n";
cout << "This gives you a " << percentage << " rate.\n";
#include<iostream>
using std::cout;
using std::cin;
int main()
{
int bottom, top;
int guess, correct=0, total=0;
float worth=0, percentage=0;
cout<< "Enter the bottom end of the range (from 0 to 10): ";
cin >> bottom;
cout<< "\nEnter the top end of the range (from 0 to 10): ";
cin >> top;
for (int a=bottom; a<=bottom; a++)
{
for (int b=bottom; b<=top; b++)
{
cout << "\n\nWhat is ? " << a << " * " << b << " = : ";
cin >> guess;
if (guess==a*b)
{
cout << " \n\ncorrect \n\n";
++correct;
}
else
cout << " \n\nSorry, the correct answer is "<<a<<" * "<<b<< " = "<<a*b<<"\n\n";
++ total;
}
}
worth=100/total;
percentage=(worth*correct);
cout << "You answered " << total << " questions in total.\n\n";
cout << correct <<" were answered correctly.\n\n";
cout << "This gives you a " << percentage << " rate.\n";
return 0;
}
#include<iostream>
using std::cout;
using std::cin;
int main()
{
int bottom, top;
int guess, correct=0, total=0;
float worth=0, percentage=0;
cout<< "Enter the bottom end of the range (from 0 to 10): ";
cin >> bottom;
cout<< "\nEnter the top end of the range (from 0 to 10): ";
cin >> top;
for (int a=bottom; a<=top; a++)
{
for (int b=bottom; b<=top; b++)
{
cout << "\n\nWhat is ? " << a << " * " << b << " = : ";
cin >> guess;
if (guess==a*b)
{
cout << " \n\ncorrect \n\n";
++correct;
}
else
cout << " \n\nSorry, the correct answer is "<<a<<" * "<<b<< " = "<<a*b<<"\n\n";
++ total;
}
}
worth=100/total;
percentage=(worth*correct);
cout << "You answered " << total << " questions in total.\n\n";
cout << correct <<" were answered correctly.\n\n";
cout << "This gives you a " << percentage << " rate.\n";
return 0;
}
Thank you that fixed it. I'm sorry when I did it I put them in backwards. Did you happen to look at the percentage. Mine is wrong. Do you know whats wrong with it?