Need help with looping menu

[EDIT]Figured it out, just replaced the if statements with a switch and ka-boom she works ;D.

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
#include <iostream>
using namespace std;
 
int main()
{
	int choice = 0;
	do
	{
		system("cls");
		cout << "|||||||||||||||||||" << endl;
		cout << "|||||| Menu |||||||" << endl;
		cout << "|||||||||||||||||||" << endl;
		cout << "                  |" << endl;
		cout << "Addition ----- (1)|" << endl;
		cout << "Subtraction -- (2)|" << endl;
		cout << "Multiplication (3)|" << endl;
		cout << "Division ----- (4)|" << endl;
		cout << "Quit --------- (5)|" << endl;
		cout << "Select: ";
		cin  >> choice;
	}
		while (choice <= 0 || choice > 5);
		if (choice == 1)
		{
			system("cls");
			double firstAdd,
				   secondAdd,
				   totalAdd;
 
			cout << "Enter first digit: ";
			cin >> firstAdd;
			cout << "Enter second digit: ";
			cin >> secondAdd;
			totalAdd = firstAdd + secondAdd;
			cout << firstAdd << " + " << secondAdd << " = " 
				 << totalAdd << endl;
			system("pause");
		}
		else if (choice == 2)
		{
			system("cls");
			double firstSub,
				   secondSub,
				   totalSub;
 
			cout << "Enter first digit: ";
			cin >> firstSub;
			cout << "Enter second digit: ";
			cin >> secondSub;
			totalSub = firstSub - secondSub;
			cout << firstSub << " - " << secondSub << " = "
				 << totalSub << endl;
			system("pause");
		}
		else if (choice == 3)
		{
			system("cls");
			float firstMulti,
				  secondMulti,
				  totalMulti;
 
			cout << "Enter first digit: ";
			cin >> firstMulti;
			cout << "Enter second digit: ";
			cin >> secondMulti;
			totalMulti = firstMulti * secondMulti;
			cout << firstMulti << " * " << secondMulti << " = "
				 << totalMulti << endl;
			system("pause");
		}
		else if (choice == 4)
		{
			system("cls");
			int firstDivi,
				secondDivi,
				remainder,
				totalDivi;
 
			cout << "Enter first digit: ";
			cin >> firstDivi;
			cout << "Enter second digit: ";
			cin >> secondDivi;
			totalDivi = firstDivi / secondDivi;
			remainder = firstDivi % secondDivi;
			cout << firstDivi << " / " << secondDivi << " = "
				 << totalDivi << "." << remainder << endl;
			system("pause");
		}
		else
		{
			system("exit");
		}
}
Last edited on
Topic archived. No new replies allowed.