box office theatre program...lost

Task A: Write a function that has ONE parameter.

At Pinocchio’s Marionette Theater, ticket prices are $5.00 for kids 12 and under, $5.00 for seniors 62 and over, and $8.00 for older kids and regular adults.

1. Write a function called boxOffice to represent the theater’s box office.
2. Your function will have a return type of void, but it will have one parameter, which will represent the patron’s age.
3. Inside your function, you will determine the ticket price based on the patron’s age (using if/else) and then display a message to the user noting the price.
4. In main, ask the user for the patron’s age and store it in a variable. Then pass that value to your boxOffice function.


Task B: Write a function that has TWO parameters.

First, comment out all code from Task A by selecting the code and clicking this button on the toolbar:


TASK B

It’s Princess Appreciation Day at the Pinocchio’s Marionette Theater, which means that all girls 12 and under get in for free. Regular prices still apply to all others (see program A).

1. Write a function called boxOffice to represent the theater’s box office.
2. Your function will have a return type of void, but it will have two parameters, one which will represent the patron’s age, and another to represent the patron’s gender.
3. Inside your function, you will determine the ticket price based on the patron’s age and gender (using if/else) and then display a message to the user noting the price.
4. In main, ask the user for the patron’s age and gender and store them in variables (use an int for age and a char for gender). Then pass those values to your boxOffice function.


TASK C
There are three plays going on at Pinocchio’s Marionette Theater this weekend: William Tell, Snow White, and Hansel and Gretel.

1. Write a function called findTheater, which will locate a theater room based on the play the patron wishes to see.
2. Your function will have one parameter which will be an integer representing the play the user wants to see: 1 for William Tell, 2 for Snow White, and 3 for Hansel and Gretel.
3. Your function will also return a string which represents the name of the room in which the play is being performed. William Tell is being shown in the “Alpine Village” room; Snow White is being shown in the “Enchanted Kingdom” room; and Hansel and Gretel will be shown in the “Black Forest” room. (Note: be sure to #include <string> at the top of your program)
4. In main, you will display a short menu to the user asking them which play they plan to see. Store the user’s choice in an integer and pass that value to the findTheater function. Also in main you will capture the string returned from your function and display it. Note: In this program ALL couts should be in main, and none should be in your function!


TASK D
Create a new program based on your program A (you may copy and paste to save time). Like program A, this program will pass the patron’s age to the boxOffice function, but it will employ a ‘pass by reference’ (instead of the default ‘pass by value’). Hint: This change can literally be made with just a couple of keystrokes!


SO this is what I have so far...task 1 i think is fine and works...
task B i think im missing something in there to make only under 12 females to work
then task c is what i need the most help on. I got lost somewhere in it and its not showing up the prompt when run...it throws an exception and kicks me out,

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
 #include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;


//void boxOffice(int age)
//
//{
//	double ticketprice;
//
//	if (age <= 12)
//		ticketprice = 5.00;
//	else if (age >= 62)
//	ticketprice = 5.00;
//	else
//	ticketprice = 8.00;
//	cout << ticketprice;
//
//
//}

task b
void boxOffice(char gender, int age)
{
		int m= 5;
		int f= 0;
		double female = 0;
		double ticketprice;
		double newticketprice;

		if (age <= 12) 
			ticketprice = 5.00;
			else if (age >= 62)
			ticketprice = 5.00;
			else
			ticketprice = 8.00;

		if (gender == female)
				newticketprice = ticketprice + f;			
		else (gender == m);
				m = ticketprice;

			cout << ticketprice;             

}

/*have to figure out why the f isnt coming out to zero
//task c

string FindTheater(int play)
{
	string Name;
	string location;

	if (play = 1)
		string Name = "William Tell", location = "Alpine Village";
	else if (play = 2)
		string Name = "Snow White", location = "enchanted kingdom";
	else if (play = 3)
		string Name = "Hansel and Gretel", location = "Black forest";

	
	return Name, location;
}

//task d
//void boxOffice(int& age) 
//{
//	double ticketprice;
//
//	if (age <= 12)
//		ticketprice = 5.00;
//	else if (age >= 62)
//	ticketprice = 5.00;
//	else
//	ticketprice = 8.00;
//	cout << ticketprice;
//
//
//}
void boxOffice(int&);

int main()

{
	int play = 0;
	string location = 0;
	string theater = FindTheater(play);
		cout << "Welcome to Pinocchio's Marionette Theater!" << endl;
		cout << " Enter Patron's age: " << endl;
		int age;
		cin >> age;
		cout << " Enter Patron's gender (m/f): " << endl;
		int gender;
		cin >> gender;
		cout << "Ticket price is: $";
	/*	boxOffice(gender);*/
		double ticketprice;
		
	/*	boxOffice(age, gender);*/
	//	cout << "Please select a play: " << endl;
	//	cout << "1) Williams Tell" << endl;
	//	cout << "2) Snow White " << endl;
	//	cout << "3) Hansel and Gretel" << endl;
	//	cout << "Enter Choice (1-3): " << endl;
	//	cin >> play;
	///*	boxOffice(age);*/
	//	theater = FindTheater(play);
	//	cout << play << "is being shown in the " + location << endl;
	

		
		system("pause");
		return 0;

}
Topic archived. No new replies allowed.