Hello all,
I am taking a C++ class after not touching it for about 4 years now... I am rather dusty. My book is horrible, I am trying to randomly select a switch case for a word output. This is my latest attempt:
*******************************************************
void right();
void wrong();
int main()
{
int a, b;
int answer;
int input;
cout << "This program will work on your multiplication up to 12\n"
<< "If you wish to quit, enter -1 to exit this program.\n";
do
{
a = rand() % 13 + 1;
b = rand() % 13 + 1;
answer = a * b;
cout << "How much is: " << a << " times " << b << "?\n\n";
cin >> input;
system("cls");
cout << endl;
if (input == answer)
right();
else
{
do
{
if (input == -1)
break;
else
wrong();
cout << "How much is: " << a << " times " << b << "?\n\n";
cin >> input;
}while (input != answer);
}
} while (input != -1);
return 0;
}
void right()
{
int c;
c = rand() % 4 + 1;
switch (c)
{
case 1:
cout << "VERY GOOD! \n";
case 2:
cout << "EXCELLENT! \n";
case 3:
cout << "COOL! \n";
default:
cout << "KEEP UP THE GOOD WORK! \n";
}
}
int wrong()
{
int d;
d = rand() % 4 + 1;
switch (d)
{
case 1:
cout << "No. Please Try Again... \n";
case 2:
cout << "Wrong Try One More Time... \n";
case 3:
cout << "Try Until You Succeed... \n";
default:
cout << "No. Keep Trying... \n";
}
}
*************************************************
The book I have is a paper weight, and I don't have any other books with me. Any ideas would be very appreciated.
Thanks,
Nate