switch (number == 1){
case 1:cout<<"The Man who laughs at himself never runs out of things to laugh at.\n "<<endl;
break;
case 2:cout<<"He who throws dirt is losing ground.\n"<<endl;
break;
case 3:cout<<"Some men dream of fortunes, others dream of cookies.\n"<<endl;
break;
case 4:cout<<"The early bird gets the worm, but the second mouse gets the cheese.\n "<<endl;
break;
case 5:cout<<"Courage is not simply one of the virtues, but the form of every virtue at the testing point.\n"<<endl;
break;
case 6:cout<<"Nothing is impossible to a willing heart.\n"<<endl;
break;
case 7:cout<<"Don't worry about money. The best things in life are free.\n "<<endl;
break;
case 8:cout<<"All things are difficult before they are easy.\n"<<endl;
break;
case 9:cout<<"A ship in a harbor is safe, but that is not why ships are built.\n"<<endl;
break;
case 10:cout<<"The usefulness of a cup is in its emptiness.\n"<<endl;
break;
case 11:cout<<"You don't need strength to let go of something. What you really need is understanding.\n"<<endl;
break;
case 12:cout<<"No snowflake in an avalanche feels responsibility.\n"<<endl;
break;
case 13:cout<<"If you eat something and no one sees you eat it, it has no calories.\n"<<endl;
break;
}
switch (number == 2){
case 1:cout<<"If you hurry through long days, you will hurry through short years. (Chinese)\n "<<endl;
break;
case 2:cout<<"With Virtue you can't be completely poor; without it you can't be truly rich. (Chinese)\n"<<endl;
break;
case 3:cout<<"Wonder is the beginning of wisdom. (Greek)\n"<<endl;
break;
case 4:cout<<"A man who uses force, is afraid of reasoning. (Kenyan)\n "<<endl;
break;
case 5:cout<<"Beauty lies in the eye of the beholder. (English)\n"<<endl;
break;
case 6:cout<<"Whoever gossips to you will gossip about you. (Spanish)\n"<<endl;
break;
case 7:cout<<"Evil enters like a needle and spreads like an oak tree. (Ethiopian)\n "<<endl;
break;
case 8:cout<<"Before you score, you first must have a goal. (Greek)\n"<<endl;
break;
case 9:cout<<"A large chair does not make a king. (Sudanese)\n"<<endl;
break;
case 10:cout<<"A teacher is better than two books. (German)\n"<<endl;
break;
}
{
while (number == 1 || number == 2){
cout<<"**************"<<endl;
cout<<"Statement Generator"<<endl;
cout<<"**************"<<endl;
cout<<"1. Quotations."<<endl;
cout<<"2. Proverbs"<<endl;
cout<<"3. Exit"<<endl;
cin>>number;
if (number == 3)
break;
}
}
}
number == 1 and number == 2 evaluate to bool. You're only supposed to write the variable (which will be compared among all the cases) within the switch' parenthesis. http://www.cplusplus.com/doc/tutorial/control/
#include<iostream>
#include<cstdlib>
#include<ctime>
usingnamespace std;
int main() {
int number, random_number; /**/
srand(time(NULL));
do { /**/
cout << "**************" << endl;
cout << "Statement Generator" << endl;
cout << "**************" << endl;
cout << "1. Quotations." << endl;
cout << "2. Proverbs" << endl;
cout << "3. Exit" << endl;
cin >> number;
if (number == 1) {/**/
random_number = 1 + rand() % 13;
switch (random_number) {
case 1:cout << "The Man who laughs at himself never runs out of things to laugh at.\n " << endl;
break;
case 2:cout << "He who throws dirt is losing ground.\n" << endl;
break;
case 3:cout << "Some men dream of fortunes, others dream of cookies.\n" << endl;
break;
case 4:cout << "The early bird gets the worm, but the second mouse gets the cheese.\n " << endl;
break;
case 5:cout << "Courage is not simply one of the virtues, but the form of every virtue at the testing point.\n" << endl;
break;
case 6:cout << "Nothing is impossible to a willing heart.\n" << endl;
break;
case 7:cout << "Don't worry about money. The best things in life are free.\n " << endl;
break;
case 8:cout << "All things are difficult before they are easy.\n" << endl;
break;
case 9:cout << "A ship in a harbor is safe, but that is not why ships are built.\n" << endl;
break;
case 10:cout << "The usefulness of a cup is in its emptiness.\n" << endl;
break;
case 11:cout << "You don't need strength to let go of something. What you really need is understanding.\n" << endl;
break;
case 12:cout << "No snowflake in an avalanche feels responsibility.\n" << endl;
break;
case 13:cout << "If you eat something and no one sees you eat it, it has no calories.\n" << endl;
break;
}
}
elseif (number == 2) {/**/
random_number = 1 + rand() % 10;
switch (random_number) { /**/
case 1:cout << "If you hurry through long days, you will hurry through short years. (Chinese)\n " << endl;
break;
case 2:cout << "With Virtue you can't be completely poor; without it you can't be truly rich. (Chinese)\n" << endl;
break;
case 3:cout << "Wonder is the beginning of wisdom. (Greek)\n" << endl;
break;
case 4:cout << "A man who uses force, is afraid of reasoning. (Kenyan)\n " << endl;
break;
case 5:cout << "Beauty lies in the eye of the beholder. (English)\n" << endl;
break;
case 6:cout << "Whoever gossips to you will gossip about you. (Spanish)\n" << endl;
break;
case 7:cout << "Evil enters like a needle and spreads like an oak tree. (Ethiopian)\n " << endl;
break;
case 8:cout << "Before you score, you first must have a goal. (Greek)\n" << endl;
break;
case 9:cout << "A large chair does not make a king. (Sudanese)\n" << endl;
break;
case 10:cout << "A teacher is better than two books. (German)\n" << endl;
break;
}
}
} while (number == 1 || number == 2); /**/
}
I've put a /**/ in places I've added code, and I've removed your while loop.