program shall allow users to choose a desired ticket and calculate the price.

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
// This program shall allow users to choose a desired ticket and calculate the price.

// Jimmy Yen

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

void main_menu() ;
void sell_standard();
void sell_premium();
void sell_VIP();
void print_total();

int main()

{
	double choice;
	const double Standard_Ticket = 20.00, 
			Premium_Ticket = 30.00,
			VIP_Ticket = 40.00;

	// Display Menu
	
	main_menu();

	// Display Ticket sells
	sell_standard();
	sell_premium();
	sell_VIP();

	// Calculate Total Tickets
	print_total();




	
		do
		{
				switch(choice)
				{
				case 'A':
						cout << "Standard Ticket.";
						sell_standard();
						break;
				case 'B':
						cout << "Premium Ticket.";
						sell_premium();
						break;
				case 'C':
						cout << "VIP Ticket.";
						sell_VIP();
						break;
				case 'D':
						cout << "Quit.";
						break;
				default:
						cout << "Please enter a valid menu choice:" << endl; 
						break;
				}
		}while(choice != 'D');

	// User inputs number of tickets

	// Output total charge

		cin.clear();
		cin.sync();

	return 0;
}

void menu()
 
{
	double choice;
    
	cout <<"                             Concert Ticket Menu                                \n\n";
	
	// display the 3 types of tickets

	cout << "A. Standard Ticket" << setw(12) << "$20.00 Each" << endl;
	cout << "B. Premium Ticket" << setw(12) << "$30.00 Each" << endl;
	cout << "A. VIP Ticket" << setw(12) << "$40.00 Each" << endl;
	cout << "D. Quit the Menu" << endl;
	cout << "Please enter your choice of A, or B, or C, or D:" << endl;
	
	// user input choice of ticket
	cin >> choice;
	cout << endl;
	}

void sell_standard()
{
	double standard;

	cout <<"For how many tickets?" << endl;
	cin >> standard;
}

void sell_premium()
{
	double premium;

	cout <<"For how many tickets?" << endl;
	cin >> premium;
}

void sell_VIP()
{
	double vip;

	cout <<"For how many tickets?" << endl;
	cin >> vip;
}

void print_total()
{
	double subTotal, tax, taxTotal, Total, standard, premium, VIP, Standard_Ticket, Premium_Ticket, VIP_Ticket;

	tax = .1;

	cout << "Standard Ticket charges:" << setw(12) << standard * Standard_Ticket << endl;
	cout << "Premium Ticket charges:" << setw(12) << premium * Premium_Ticket << endl;
	cout << "VIP Ticket charges:" << setw(12) << VIP * VIP_Ticket << endl;

	subTotal = standard + premium + VIP;

	cout << "Sub Total:" << setw(12) << subTotal << endl;
	
	taxTotal = subTotal * tax;

	cout << "Tax:" << setw(12) << taxTotal << endl;

	Total = subTotal + taxTotal;

	cout << "Total charges:" << setw(12) << Total << endl;
}




Everything is set to run but only problem is the double choice;. It is illegal with the switch function but I dont know what else to use. Please help.
Seems like you want people to enter a letter? One of A, B, C or D? If only there was some kind of basic type that was made for storing character information...

As it is, your code won't work anyway, as your code for getting the user's choice is in a separate function, menu(), and when that function ends you're throwing away their choice. You've not understood how functions work when it comes to variables being passed around.
Ok? suggestions on how to set up the functions correctly?
If you want to use a function to change a value, you need to pass that value in by pointer or reference, or have it return the new value.

http://www.cplusplus.com/doc/tutorial/functions/
Make sure you read "Scope of Variables" carefully
Topic archived. No new replies allowed.