Simple Point of Sale program

I'm in the middle of creating a point of sale program which simply offers two choices, one for each imaginary "course".
My main problem is that it keeps closing in on itself when I type anything other than 'b'.
I have to stress that I can't use anything more advanced than do-while or and/or functions.
Here is the code:
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
  #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

	cout << "Would you like a burger (type 'b') or hotdog (type 'hd')?"; //User chooses entree
	cin >> entree; //User enters option: Here's where the problems begin
	if (entree == 'b') {
		cout << "Added price: " << burger;			//Explains current price
	}
	else if (entree == 'hd') {
		cout << "Added price: " << hotdog;			//Explains current price
		}
	else {
		cout << "Sorry, I didn't catch that. Please enter 'b' or 'hd'.";
	}
	cout << "Would you like French fries (type 'ff') or onion rings (type 'or')?"; // To sides
	cin >> side;
	if (side == 'ff') {
	cout << "You chose French fries!";
cout << "Added price: " << fries;
	}			
	else if (side == 'or') { // Now to onion rings
		cout << "You chose onion rings!";
cout << "Added price: " << rings;
	}
	else{
		cout << "Sorry, I didn't catch that. Please enter 'ff' or 'or'.";
	}
		
cout << "Would you like a soda (type 's') or a milkshake? (type 'm')?"; // Beverage
cin >> beverage;
		
		if (beverage == 's') {
				
				cout << "You chose a soda!";
cout << "Added price: " << soda;
			}
		else if (beverage == 'm') { // If 
				cout << "You chose a milkshake!";
cout << "Added price: " << shake;
			}
		else {
				cout << "Sorry, I didn't catch that. Please enter 's' or 'm'.";
			}
		}

	
	cout << "Please press a key and <enter> to exit: ";
	cin >> exit;
	return 0;
}

Notice that I haven't started on a receipt yet. I will also need guidance when it comes to that.
I had also considered using nested if-else statements, which I will post at a later time.
Last edited on
your main body is closing at line no 59

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
#include<iostream>
using namespace std;

int main() {
	char exit;
	char entree[2]; // char take one byte
	double burger = 3.50;			// Cost of burger equals $3.50
	double hotdog = 2.50;			// Cost of hot dog equals $2.50
	char side[2];
	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

	cout << "Would you like a burger (type 'b') or hotdog (type 'hd')?";
	cin >> entree;
	if (entree == 'b') {
		cout << "Current subtotal: " << burger;			//Explains current price
	}
	else if (entree == 'hd') {
		cout << "Current subtotal: " << hotdog;			//Explains current price
	}
	else {
		cout << "Sorry, I didn't catch that. Please enter 'b' or 'hd'.";
	}
	cout << "Would you like French fries (type 'ff') or onion rings (type 'or')?"; // To sides
	cin >> side;
	if (side == 'ff') {
		cout << "You chose French fries!";
	}			//Explains current price
	else if (side == 'or') { // Now to onion rings
		cout << "Thanks for visiting!";
	}
	else{
		cout << "Sorry, I didn't catch that. Please enter 'ff' or 'or'.";
	}

	cout << "Would you like a soda (type 's') or a milkshake? (type 'm')?"; // Beverage
	cin >> beverage;

	if (beverage == 's') {

		cout << "Thanks for visiting!";
	}
	else if (beverage == 'm') {

		cout << "Thanks for visiting!";
	}
	else {
		cout << "Sorry, I didn't catch that. Please enter 'soda' or 'milk'.";
	}

	cout << "Please press a key and <enter> to exit: ";
	cin.get(); // wait for any key to return 
	return 0;
}

Last edited on
Topic archived. No new replies allowed.