Switch menu help

Hello, I am a new c++ student and I am trying to make a menu based program that will display math problems based on the user's input. I have gotten the menu to display as a function (as required by the teacher) but I can not get the switch statement to display anything. I am not sure if the variable menuChoice is being sent back to the main as it should be. I want to be able to enter 1 for a menu choice and, for now, just display the word "Addition". Thanks for any help!

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
  // This program will show what a student recieved on a test

#include <iomanip>
#include <iostream>
#include <time.h>
#include <cstdlib>
#define over4 "\t\t\t\t"
#define down5 "\n\n\n\n\n"
#define over3 "\t\t\t"

using namespace std;

int menu();
void menuError (int);
void splash();
void welcome();
void equation();


int main ()
{
	int num1, num2, countRight, countWrong, menuChoice;
	const int ADDITION = 1, 
			  SUBTRACTION = 2, 
			  MULTI = 3, 
			  DIV = 4, 
			  MODULUS = 5, 
			  EXIT = 6;
	
	unsigned seed = time(0);
	srand(seed);
	num1 = 1 +rand() % 10;
	num2 = 1 +rand() % 10;

	
	do
	{
		
	menu ();
		
		switch (menuChoice)
		{
			case 1: cout << "Addition";
					break;
			case 2: cout << "Subtraction";
					break;
			case 3: cout << "Multiplication";
					break;	   
			case 4: cout << "Division";
					break;
			case 5: cout << "Modulus";
					break;
			case 6: cout << "Exit";
					break;		  
		}
	}while (menuChoice != EXIT);
}

int menu ()
{
	int menuChoice;

	cout << down5;
	cout << over3 << "1. Addition                       \n";
	cout << over3 << "2. Subtraction                    \n";
	cout << over3 << "3. Multiplication                 \n";
	cout << over3 << "4. Integer Division               \n";
	cout << over3 << "5. Modulus                        \n";
	cout << over3 << "6. Exit                           \n";
	cout << over3 << "   option:  ";
	cin >> menuChoice;
	return(menuChoice);
	system("CLS");
}
Line 73 has no effect. everything after a non conditional return is not executed.

For you problem:
On line 39 you need to store the result of menu (); in the variable menuChoice in order to use it:
menuChoice = menu ();
Ok thank you! I got the word addition to display. However, it displays right under the menu and a copy of the menu displays right underneath. How do I clear the screen and display the word Addition on a blank screen?
move line 73 before line 72
Thank your for all your help.
I have come across another another problem working on the Addition equation. I am getting the following error:

69 39 C:\Users\krisr_000\Desktop\C++ Projects\kkr_lab10_p1.cpp [Error] invalid conversion from 'int' to 'const char*' [-fpermissive]

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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*

Programmer name:	Kris Rossman
date:				10/20/2013
assignment:			Lab 8 Part 2

description:		First menu based program                                              
	
INPUTS:
	cin - menu choice                          
OUTPUTS:
	cout - menu, user selection, counter table       
*/

#include <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <time.h>
#include <fstream>
#define myDate 		"October 20th, 2013            "
#define myActivity  "Lab 8 Part 2                  "
#define line1  "   This program asks the user to select an option  "
#define line2  "   from a menu.  Later on in development, there    "
#define line3  "   will be further information.                    "
#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;

int menu();
void menuError (int);
void splash();
void welcome();
void equation(string, int, int, char);
int answer();

int main ()
{
	int num1, num2, countRight, countWrong, menuChoice;
	const int ADDITION = 1, 
			  SUBTRACTION = 2, 
			  MULTI = 3, 
			  DIV = 4, 
			  MODULUS = 5, 
			  EXIT = 6;
	
	unsigned seed = time(0);
	srand(seed);
	num1 = 1 +rand() % 10;
	num2 = 1 +rand() % 10;

	
	do
	{
	system("CLS");	
	menuChoice = menu ();
	
		switch (menuChoice)
		{
			case 1: system("CLS");
					cout << down5 << over4;
					equation(num1,num2,'+',"Addition");
					cout << answer();
					system("PAUSE");
					break;
			case 2: cout << "Subtraction";
					break;
			case 3: cout << "Multiplication";
					break;	   
			case 4: cout << "Division";
					break;
			case 5: cout << "Modulus";
					break;
			case 6: cout << "Exit";
					break;		  
		}
	}while (menuChoice != EXIT);
}
void equation(int num1, int num2, char symbol, string operation)
{
	cout << down8;
	cout << over4 << operation << endl
		 << over4 << "---------" << endl;
	cout << over4 << ' ' << setw(3) << num1 << endl
	     << over4 << symbol << setw(3) << num2 << endl
	     << over4 << "----" << endl << over4;
	cin >> userAnswer;

}
int menu ()
{
	int menuChoice;

	cout << down5;
	cout << over3 << "1. Addition                       \n";
	cout << over3 << "2. Subtraction                    \n";
	cout << over3 << "3. Multiplication                 \n";
	cout << over3 << "4. Integer Division               \n";
	cout << over3 << "5. Modulus                        \n";
	cout << over3 << "6. Exit                           \n";
	cout << over3 << "   option:  ";
	cin >> menuChoice;
	return(menuChoice);

}

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

the function on line 86 does not match the prototype on line 41
Topic archived. No new replies allowed.