Point of Sale Program

This program works just fine when I enter "b" as "entree", but it loops back to the opening statement when I enter "hd". When I enter "ff" after I've typed "b", however, it also closes. Can someone help me here?

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

using namespace std;

int main() {
	char exit;

	char entree;
	double burger = 3.50;			// Cost of burger equals $3.50
	double hotdog = 2.50;			// Cost of hot dog equals $2.50
	char side;
	double fries = 1.50;			// Cost of French fries equals $1.50
	double rings = 2.00;			// Cost of onion rings equals $2.00
	char beverage;
	double soda = 1.00;				// Cost of soda equals $1.00
	double shake = 3.25;			// Cost of shake equals $3.25
	double tax = 1.0825;			// Tax in Woodland, California
	double subtotal = 0;	// Subtotal
	double display;

	do {
		cout << "Would you like a burger (type 'b') or hotdog (type 'hd')?";
		cin >> entree;
		if (entree == 'b') {
			cout << "Current subtotal: " << subtotal + burger << endl;			//Explains current price
			cout << "Would you like French fries (type 'ff') or onion rings (type 'or')?";		//Sides
			cin >> side;
			if (side == 'ff') {
				display = subtotal + burger + fries;
				cout << "Current subtotal: " << subtotal;			//Explains current price
				cout << "Would you like a soda (type 's') or a milkshake? (type 'm')?"; // Beverage
				cin >> beverage;
				if (beverage == 's') {
					display = subtotal + burger + fries + soda;

					cout << "Current subtotal: " << subtotal << endl;
					cout << "Thanks for visiting!";
				}
				else if (beverage == 'm') {
					display = subtotal + burger + fries + shake;
					cout << "Current subtotal: " << display << endl;
					cout << "Thanks for visiting!";
				}
				else {
					cout << "Sorry, I didn't catch that. Please enter 'soda' or 'milk'.";
				}
			}
			else if (side == 'or') {
				display = subtotal + burger + rings;
				cout << "Current subtotal: " << subtotal << endl;
				cout << "Would you like a soda (type 's') or a milkshake? (type 'm')?";
				cin >> beverage;
				if (beverage == 's') {
					display = subtotal + burger + soda + rings;
					cout << "Current subtotal: " << subtotal << endl;
					cout << "Thanks for visiting!";
				}
				else if (beverage == 'm') {
					display = subtotal + burger + shake + rings;
					cout << "Current subtotal: " << subtotal << endl;
					cout << "Thanks for visiting!";
				}
				else {
					cout << "Sorry, I didn't catch that. Please enter 'soda' or 'milk'.";
				}
			}

			else {
				cout << "Sorry, I didn't catch that. Please enter 'ff' or 'or'. \n\n";
			}
		}
	
	

		else if (entree == 'hd') {
			cout << "Current subtotal: " << subtotal + hotdog;			//Explains current price
			cout << "Would you like French fries (type 'ff') or onion rings (type 'or')?";		//Sides
			cin >> side;
			if (side == 'ff') {
				cout << "Current subtotal: " << subtotal + hotdog + fries;			//Explains current price
				cout << "Would you like a soda (type 's') or a milkshake? (type 'm')?";
				cin >> beverage;
				if (beverage == 's') {
					cout << "Current subtotal: " << subtotal + hotdog + soda + fries;
					cout << "Thanks for visiting!";
				}
				else if (beverage == 'm') {
					cout << "Current subtotal: " << subtotal + hotdog + shake + fries;
					cout << "Thanks for visiting!";
				}
				else {
					cout << "Sorry, I didn't catch that. Please enter 'soda' or 'milk'.\n\n";
				}
			}

			else if (side == 'or') {
				cout << "Current subtotal: " << subtotal + hotdog + rings;
				cout << "Would you like a soda (type 's') or a milkshake? (type 'm')?";
				cin >> beverage;
				if (beverage == 's') {
					cout << "Current subtotal: " << subtotal + hotdog + soda + rings;
					cout << "Thanks for visiting!";
				}
				else if (beverage == 'm') {
					cout << "Current subtotal: " << subtotal + hotdog + shake + rings;
					cout << "Thanks for visiting!";
				}
				else {
					cout << "Sorry, I didn't catch that. Please enter 'soda' or 'milk'. \n\n";
				}
			}
			else {
				cout << "Sorry, I didn't catch that. Please enter 'ff' or 'or'.\n\n";
			}
		}

	else {
		cout << "Sorry, I didn't catch that. Please enter 'b' or 'hd'.";
	}
	
	
	} while (entree != 'b' && entree != 'hd');

	
	cout << "Please press a key and <enter> to exit: ";
	cin >> exit;
	return 0;
}
Last edited on
@JarrodBaniqued

The variable, entree, is a char, meaning it can only hold a single character, whereas, your typing two in some instances. Same with side. It also can only hold one character.
you need give char a size because if you don't give him the size the default char takes 1byte

 
  char name[10];//now you can write up to 10 char e.g abcdefghij 
I edited it. Now it's
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
#include <iostream>

using namespace std;

int main() {
	char exit;

	char entree;
	double burger = 3.50;			// Cost of burger equals $3.50
	double hotdog = 2.50;			// Cost of hot dog equals $2.50
	char side;
	double fries = 1.50;			// Cost of French fries equals $1.50
	double rings = 2.00;			// Cost of onion rings equals $2.00
	char beverage;
	double soda = 1.00;				// Cost of soda equals $1.00
	double shake = 3.25;			// Cost of shake equals $3.25
	double tax = 1.0825;			// Tax in Woodland, California
	double subtotal = 0;	// Subtotal
	double display;

	do {
		cout << "Would you like a burger (type 'b') or hotdog (type 'h')?";
		cin >> entree;
		if (entree == 'b') {
			cout << "Current subtotal: " << subtotal + burger << endl;			//Explains current price
			cout << "Would you like French fries (type 'f') or onion rings (type 'r')?";		//Sides
			cin >> side;
			if (side == 'f') {
				display = subtotal + burger + fries;
				cout << "Current subtotal: " <<display << endl;			//Explains current price
				cout << "Would you like a soda (type 's') or a milkshake? (type 'm')?"; // Beverage
				cin >> beverage;
				if (beverage == 's') {
					display = subtotal + burger + fries + soda;

					cout << "Current subtotal: " <<display << endl;
					cout << "Thanks for visiting!";
				}
				else if (beverage == 'm') {
					display = subtotal + burger + fries + shake;
					cout << "Current subtotal: " << display << endl;
					cout << "Thanks for visiting!";
				}
				else {
					cout << "Sorry, I didn't catch that. Please enter 'soda' or 'milk'.";
				}
			}
			else if (side == 'r') {
				display = subtotal + burger + rings;
				cout << "Current subtotal: " <<display << endl;
				cout << "Would you like a soda (type 's') or a milkshake? (type 'm')?";
				cin >> beverage;
				if (beverage == 's') {
					display = subtotal + burger + soda + rings;
					cout << "Current subtotal: " <<display << endl;
					cout << "Thanks for visiting!";
				}
				else if (beverage == 'm') {
					display = subtotal + burger + shake + rings;
					cout << "Current subtotal: " <<display << endl;
					cout << "Thanks for visiting!";
				}
				else {
					cout << "Sorry, I didn't catch that. Please enter 'soda' or 'milk'.";
				}
			}

			else {
				cout << "Sorry, I didn't catch that. Please enter 'f' or 'r'. \n\n";
			}
		}
	
	

		else if (entree == 'h') {
			cout << "Current subtotal: " << subtotal + hotdog;			//Explains current price
			cout << "Would you like French fries (type 'f') or onion rings (type 'r')?";		//Sides
			cin >> side;
			if (side == 'f') {
				cout << "Current subtotal: " << subtotal + hotdog + fries;			//Explains current price
				cout << "Would you like a soda (type 's') or a milkshake? (type 'm')?";
				cin >> beverage;
				if (beverage == 's') {
					cout << "Current subtotal: " << subtotal + hotdog + soda + fries;
					cout << "Thanks for visiting!";
				}
				else if (beverage == 'm') {
					cout << "Current subtotal: " << subtotal + hotdog + shake + fries;
					cout << "Thanks for visiting!";
				}
				else {
					cout << "Sorry, I didn't catch that. Please enter 'soda' or 'milk'.\n\n";
				}
			}

			else if (side == 'r') {
				cout << "Current subtotal: " << subtotal + hotdog + rings;
				cout << "Would you like a soda (type 's') or a milkshake? (type 'm')?";
				cin >> beverage;
				if (beverage == 's') {
					cout << "Current subtotal: " << subtotal + hotdog + soda + rings;
					cout << "Thanks for visiting!";
				}
				else if (beverage == 'm') {
					cout << "Current subtotal: " << subtotal + hotdog + shake + rings;
					cout << "Thanks for visiting!";
				}
				else {
					cout << "Sorry, I didn't catch that. Please enter 's' or 'm'. \n\n";
				}
			}
			else {
				cout << "Sorry, I didn't catch that. Please enter 'f' or 'r'.\n\n";
			}
		}

	else {
		cout << "Sorry, I didn't catch that. Please enter 'b' or 'h'.";
	}
	
	
	} while (entree != 'b' || entree != 'h' || side != 'f' || side != 'r' || beverage != 's' || beverage != 'm');

	
	cout << "Please press a key and <enter> to exit: ";
	cin >> exit;
	return 0;
}
I already resolved the creation of receipt issues (I don't have a copy of the program with me right now). All I need to do is resolve issues surrounding do-while loops. Can anyone pinpoint the way?
Last edited on
Topic archived. No new replies allowed.