Looping Menu with Random outputs Problem

It seems that I am having a problem with this line of code.

The case label value exceeds the maximum value for the type.
The looping of the menu is not outputting properly.

I am looking to utilize the while loops, while also utilizing the rand function.

#include<iostream>
#include<cstdlib>
#include<ctime>

using namespace std;


int main(){

int number;
srand(time(NULL));

cout<<"**************"<<endl;
cout<<"Statement Generator"<<endl;
cout<<"**************"<<endl;
cout<<"1. Quotations."<<endl;
cout<<"2. Proverbs"<<endl;
cout<<"3. Exit"<<endl;
cin>>number;

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;
}
}
}

Thank You.
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/

I modified your code a tiny bit.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include<iostream>
#include<cstdlib>
#include<ctime>

using namespace 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;
				}
		}

		else if (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.
Topic archived. No new replies allowed.