Question: You are to write a program that allows a user purchase tickets to a Broadway musical. The program asks the user how much money they

You are to write a program that allows a user purchase tickets to a Broadway musical. The
program asks the user how much money they have to spend on tickets and then asks them how
many tickets they would like to purchase. The program must implement the following function
that is called once the user has entered all the information:
/*****************************************************************
*
*
Function: PurchaseTickets
*
*
Parameters:
*
*
pRemainingCash
-
points to a variable containing the
*
amount of cash the user has
*
*
adultTickets
-
specifies the number of adult tickets
*
the user wants to purchase.
*
*
childTickets
-
specifies the number of child tickets
*
the user wants to purchase.
*
**
Description:
*
The function will determine if the user has enough
*
money to purchase the specified number of tickets.
*
If they do
,
then the function deducts the proper
*
funds from their remaining cash and returns
*
the total number of tickets purchased. If they do not
*
the function returns
0
.
*
******************************************************************/
int PurchaseTickets
(
double
*
pRemainingCash
,
int adultTickets,
int childTickets
)
;
You must also use the following two constants to represent the ticket prices:
#define ADULT
_
TICKET
_
PRICE
69.00
#define CHILD
_
TICKET
_
PRICE
35.00
The program must prompt the user for the following information and in the following order:
Amount of cash they have
Number of child tickets to purchase
Number of adult tickets to purchase
If the user has enough money to purchase the requested tickets, display the number of tickets
they purchased and the remaining cash they have after the purchase. If the user does not have
enough money to purchase the tickets, tell them and exit the program.
Here are two sample interactions:
Sample
1
:
How much money do you have to purchase tickets?
300.00
How many child tickets would you like to purchase?
2
How many adult tickets would you like to purchase?
3
You have purchased
5
tickets, and you have $
23.00
remaining
Sample
2
:
How much money do you have to purchase tickets?
100.00
How many child tickets would you like to purchase?
2
How many adult tickets would you like to purchase?
4
You do not have enough money to purchase the tickets
Here is what I have so far:
#include
#define ADULT
_
TICKET
_
PRICE
69.00
#define CHILD
_
TICKET
_
PRICE
35.00
int PurchaseTickets
(
double
*
pRemainingCash
,
int adultTickets, int childTickets
)
;
int main
(
void
)
{
double cash;
int childTickets;
int adultTickets;
//
printf to ask for the amount of cash
printf
("
How much money do you have to purchase tickets?:
")
;
//
scanf and error checking
scanf
("
%
d
"
,
cash
)
;
//
ask for number of child tickets
printf
("
How many child tickets would you like to purchase?:
")
;
//
scanf and error checking
scanf
("
%
d
"
,
childTickets
)
;
//
ask for number of adult tickets
printf
("
How many adult tickets would you like to purchase?:
")
;
//
scanf and error checking
scanf
("
%
d
"
,
adultTickets
)
;
if
(
PurchaseTickets
(
&cash, adultTickets, childTickets
)
>
0)
{
printf
("
You have purchased
%
d tickets, and you have $
%
3.2
f remaining.", adultTickets
+
childTickets, cash
)
;
}
else
{
printf
("
You did not purchase any tickets.
")
;
}
return
0
;
}
int PurchaseTickets
(
double
*
pRemainingCash
,
int adultTickets, int childTickets
)
{
int numTicketsPurchased
=
0
;
return numTicketsPurchased;
//
if user does not have enough money for the tickets
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!