Loop Menu

I have to create a program that will loop a basic menu prompting the user to enter a menu selection. I can not figure out why the program is not looping. I am a new C++ student in college. If anyone can point me in the right direction i would appreciate it.



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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
  /*

Programmer name:	Kris Rossman
date:				10/11/2013
assignment:			Lab 8 Part 1

description:		First menue based program                                              
	
INPUTS:
	cin - the name of the file                 
OUTPUTS:
	cout - The fortune teller's prediction and the summary of jobs in file
*/

#include <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <time.h>
#include <fstream>
#define myDate 		"October 20th, 2013            "
#define myActivity  "Lab 8 Part 1                  "
#define line1  "   This program asks the user to enter the name    "
#define line2  "   of a file.  Then a list of jobs will appear     "
#define line3  "   with a prediction for the user.                 "
#define over2  "\t\t"
#define over3  "\t\t\t"
#define over4  "\t\t\t\t"
#define down5  "\n\n\n\n\n"
#define down8  "\n\n\n\n\n\n\n\n"
#define down10 "\n\n\n\n\n\n\n\n\n\n"
#define down12 "\n\n\n\n\n\n\n\n\n\n\n\n"                                                  

using namespace std;

//void splash();
//void welcome();


int main(int argc, char *argv[]) 
{
	int menuChoice;
	do 
	{
	
	cout << down5;
	cout << over3 << "Health Club Membership Program.\n";
	cout << over3 << "-------------------------------\n";
	cout << over3 << "1. Standard Adult Membership   \n";
	cout << over3 << "2. Child Membership            \n";
	cout << over3 << "3. Senior Citizen Membership   \n";
	cout << over3 << "4. Exit                        \n";
	cout << over3 << "option: ";
	cin >> menuChoice;
	
		if (menuChoice == 1)
			{
				cout << "Submit completed work for part 1!";
			}
		else if (menuChoice == 2)
			{
				cout << "Submit completed work for part 1!";
			}
		else if (menuChoice == 3)
			{
				cout << "Submit completed work for part 1!";
			}
		else if (menuChoice == 4)
			{
				cout << "Submit completed work for part 1!";
			}
		else 
			{
				cout << "Make a menu selection between 1 and 4. Re-run the program and try again.";
			}
		
		return 0;
	}while (menuChoice != 4);
	
	

	
}

void splash ()
{
	system("CLS");
	cout << "\n\n\n"
		 << "\n\t\t	       _ "	 
		 << "\n\t\t              (_)          _ "
		 << "\n\t\t          _         .=.   (_) "
		 << "\n\t\t         (_)   _   //(`)_            \"By blood a king,    "
		 << "\n\t\t              //`\\/ |\\ 0`\\\\           in heart a clown.\"  "
		 << "\n\t\t              ||-.\\_|_/.-||          ~Alfred Lord Tennyson"
		 << "\n\t\t              )/ |_____| \\(    _ "
		 << "\n\t\t             0   #/\\ /\\#  0   (_) "
		 << "\n\t\t                _| o o |_ "
		 << "\n\t\t         _     ((|, ^ ,|)) "
	 	 << "\n\t\t        (_)     `||\\_/||` "
	 	 << "\n\t\t                 || _ ||      _ "
		 << "\n\t\t                 | \\_/ |     (_) "
	 	 << "\n\t\t             0.__.\\   /.__.0 "
		 << "\n\t\t              `._  `\"`  _.' "
		 << "\n\t\t       kkr       / ;  \\ \\ "
		 << "\n\t\t               0'-' )/`'-0 "
		 << "\n\t\t                   0` "
		 << "\n\n\n";

	system("PAUSE");
}	
	
void welcome()
{
	system("CLS");
	cout << "\n\n\n";	
	cout << "\n\t/--------------------------------------------------------------\\";
	cout << "\n\t|                      About This Program                      |";
	cout << "\n\t+--------------------------------------------------------------+";
	cout << "\n\t|                                                              |";
	cout << "\n\t|                                                              |";
	cout << "\n\t|             Programmer's Name: Kris Rossman                  |";
	cout << "\n\t|                          Date: "myDate                      "|";        
	cout << "\n\t|               Name of program: "myActivity                  "|";
	cout << "\n\t|                                                              |";
	cout << "\n\t|    /-------------------- Description --------------------\\   |";
	cout << "\n\t|    | "   line1                                         " |   |";
	cout << "\n\t|    | "           line2                                 " |   |";
	cout << "\n\t|    | "                         line3                   " |   |";
	cout << "\n\t|    \\-----------------------------------------------------/   |";
	cout << "\n\t|                                                              |";
	cout << "\n\t|                                                              |";
	cout << "\n\t|                                                              |";
	cout << "\n\t\\--------------------------------------------------------------/";
	cout << "\n\n\n";
	system("PAUSE");
}
delete return 0; on line 77
return 0; in your main function should come after the end of your loop. When there is a 'return' statement is executed inside a function, the program will read the 'return' statement and ignore any code inside that function after the 'return' statement. And due to the fact that your 'return' statement is in your main function, the program skips the code after the 'return' statement (the end of your loop) and ends the entire program.

Hope that helped you out a little. :D
Topic archived. No new replies allowed.