For this assignment, write a program that will calculate the amount that a customer spends on tickets at a movie theater.
The program should:
Prompt the user for the number of adult tickets they would like to purchase
Prompt the user for the number of childrens tickets they would like to purchase
Prompt the user to determine if they have a discount coupon ("Y" for yes, anything else for no)
If the user has a discount coupon, determine if it's for a free adult ticket or for a free childrens ticket ("A" for adult, "C" for child, anything else is an error)
Calculate the user's purchase amount
Display the number of adult tickets that were purchased, the number of childrens tickets that were purchased, the discount amount (if a discount was applied to the purchase), and the total purchase amount.
Calculations
An adult ticket costs $10.50 while a child's ticket costs $5.00.
The purchase amount is the cost of adult tickets plus the cost of childrens tickets minus the discount (if any).
Processing Requirements
All of the calculated dollar amounts should be displayed with exactly 2 digits after the decimal point.
The numeric values read in from the user should all be integer values. The discount values read in from the user should all be string values. Use meaningful variable names.
Output
A few runs of the program should produce the following results:
Run 1
Enter the number of adult tickets that are being purchased: 2
Enter the number of child tickets that are being purchased: 5
Do you have a discount coupon (Y for yes)? Y
Is the discount for an adult or child's ticket (A for adult, C for child)? C
****************************************
Theater Sale
****************************************
Number of adult tickets: 2
Number of child tickets: 5
Discount: 5.00
Total purchase: 41.00
Run 2
Enter the number of adult tickets that are being purchased: 1
Enter the number of child tickets that are being purchased: 2
Do you have a discount coupon (Y for yes)? n
****************************************
Theater Sale
****************************************
Number of adult tickets: 1
Number of child tickets: 2
That is the problem i have to do for class but i don't know where to start, and what necessarily to write for the program. I guess i don't understand what i really have to do and how to write it in C++ programming.
I think im over thinking the problem. For some reason i just dont get C++ programming but i need it for a minor. Later on i will provide some code and i will be thankful if you could help me with it.
int main()
{
double adult, child;
int priceAdult, priceChild, total;
string couponType, discount;
//get the number of adult tickets they would like to purchase
cout << "Enter the amount of adult tickets that are being purchased: ";
cin >> adult;
//get the number of child tickets they would like to purchase
cout << "Enter the amount of child tickets that are being purchased: ";
cin >> child;
//If the user has a coupon
// Ask for a discount coupon
cout << "Do you have a discount coupon? (Y for yes, anything else for no): ";
cin >> couponType;
if ( couponType == "Y" )
{
//ask whether it is for adult or child
cout << "Is this coupon for an adult or child ticket?(A for adult, C for Child): ";
if ( discount == "A" )
{
total = priceAdult - 10.50;
cout << "Discount: " << priceAdult << endl;
}
else ( discount == "C" );
{
total = adult * 10.50 ;
}
}
else
{
total = priceAdult + priceChild;
}
cout << endl;
return 0;
}