Simple Menu and Loop with functions

I am trying to display a menu using string Menu(), but I do not see the program at all when I run it. Can anyone tell me what I am doing wrong?

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
#include <iostream>
#include <iomanip>

using namespace std;

int Sum;
int Count;
int number;
int M;
int N;
int number1;
int number2;
int number3;
int number4;

/* Function Prototypes*/

string Menu();

int getValue("Enter a Number",0,10000);

void doAverage();
double calcAverage(int Sum,int Count);

void doFactorial();
int calcFactorial(int number);

void doMtoNth();
int calcMtoNth(int M,int N);

void doRange();
int calcRange(int number1,int number2,int number3,int number4);


int main()
{
string userChoice;

userChoice = Menu();

while ( userChoice != "Q" && userChoice != "q")
	{
	if (userChoice == "1")
		{
		cout << "Enter sum:" << endl;
		cin >> Sum;
		cout << "Enter total count:" << endl;
		cin >> Count;
		
		doAverage();
		
		cout << "The average of " << Sum << " and " << Count << "is " << Average << endl;
		}
	else if (userChoice == "2")
		{
		cout << "Enter a number between 0 and 10:" << endl;
		cin >> number;
		
		doFactorial();
		
		cout << "The factorial of " << number << " is " << Factorial << endl;
		}
	else if (userChoice == "3")
		{
		cout << "Enter the M value between 1 and 10:"<< endl;
		cin >> M;
		cout << "Enter the N value between 1 and 8:" << endl:
		cin >> N;
		
		doMtoNth();
		
		cout << M << "Raised to the" << N << "th Power is " << Mth << endl; 
		}
	else if (userChoice == "4")
		{
		cout << "Enter a number between 0 and 10000: " << endl;
		cin >> number1;
		cout << "Enter another number between 0 and 10000: " << endl:
		cin << number2;
		cout << "Enter another number between 0 and 10000: " << endl:
		cin >> number3;
		cout << "Enter another number between 0 and 10000: " << endl:
		cin >> number4;
		
		doRange();
		
		cout << "The range of " << number1 << ", " << number2 << ", " << number3 << "and " << number4 << " is " << Range << endl;  
		}
userChoice = Menu();



system ("pause");
return 0;
}


An example output is listed below. It is supose to loop until Q or q is entered. I am not getting this at all.


Special Purpose Calculator

1) Average
2) Factorial
3) M to the Nth Power
4) Range

Q) Quit

Enter your choice: 2

Enter a number between 0 and 10: 8

The facotrial of 8 is 40320




Special Purpose Calculator

1) Average
2) Factorial
3) M to the Nth Power
4) Range

Q) Quit

Enter your choice: 3

Enter the M value between 1 and 10: -5
Error: -5 is invalid. Try again: 17
Error: 17 is invalid. Try again: 9

Enter the N value between 1 and 8: 3

9 raised to the 3th power is 729




Special Purpose Calculator

1) Average
2) Factorial
3) M to the Nth Power
4) Range

Q) Quit

Enter your choice: 567
Error: 567 is invalid. Try again: 78
Error: 78 is invalid. Try again: 6
Error: 6 is invalid. Try again: -1
Error: -1 is invalid. Try again: 4

Enter a number between 0 and 10000: 100

Enter another number between 0 and 10000: 53

Enter another number between 0 and 10000: 222

Enter another number between 0 and 10000: 718

The range of 100, 53, 222 and 718 is 665




Special Purpose Calculator

1) Average
2) Factorial
3) M to the Nth Power
4) Range

Q) Quit

Enter your choice: Q



I know some of the variables are not declared like Range, Average, Factorial, etc.. but if anyone sees anything wrong please let me know! thanks in advance!!
Last edited on
And where is your function menu()?
I havent gotten go that yet. I do not know how go make it yet but I am working on it (BEGINNER!!!) LOL
closed account (zb0S216C)
Any invocations to a function without a definition will result in undefined references. These are errors which indicate that the linker cannot locate the definition of the function you're trying to invoke.

In the condition of the while, instead of logical AND, use logical OR.

Wazzak
I think that instead of using of string menu() it would be better to declare this function either as char menu() or enum SomeEnum menu()
Topic archived. No new replies allowed.