### Need help with C++ problem? (don't know how to write the code)

Overview

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 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 child tickets: 2

Total purchase: 20.50
So what do you need help with?
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.
The assignment is pretty clear, and usually the course gives enough info through lectures, tutorials etc, to be able to do the assignment.

So where is the problem? You must have some idea? We will not do your homework for you - it's against the rules of the forum.

Show us some code.
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.
It might help if you write comments that document the steps you need to carry out the assignment.

You can do this incrementally:

 ``1234`` ``````//Prompt for number of tickets //prompt for discount //calc cost //display ``````

So this is the basic outline, now go back and add more detail:

 ``1234567891011`` ``````//Prompt for number of tickets //variables needed //adult tickets //children's tickets //prompt for discount //calc cost //display //adult //children's //discount //total cost ``````

So keep doing this until you are happy to write code. Leave the comments there as they are documentation.

Doing this will help organise your thoughts, and help identify which code needs to be in a function.

The layout for the file should generally be like this:

 ``123456789101112131415161718`` ``````//include statements //using statements //function declarations //returntype Myfunction (argument types); int main() { return 0; } //function defintions //returntype Myfunction(parameters with types) { //function code here return //variable of returntype unless it's void }``````

HTH
Last edited on

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
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: ";

//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" )
{
cout << "Is this coupon for an adult or child ticket?(A for adult, C for Child): ";

if ( discount == "A" )
{
cout << "Discount: " << priceAdult << endl;
}
else ( discount == "C" );
{
total = adult * 10.50 ;
}
}
else
{