Everything seems to be working but the name

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
//Constants for adult and child ticket costs
const double cost_per_child_ticket = 2.25;
const double cost_per_adult_ticket = 5.50;

//Variables
double adult, //Amount of adult tickets sold
child, //Amount of child tickets sold
movie, //Holds movie name
gross_adult_ticket, // Holds gross amount of adult tickets
gross_child_ticket, // Holds gross amount of child tickets
total_box_office_profit, //Holds total box office profit
net_box_office_profit, //Holds total earnings for theater
amount_paid_distributor; //Holds final amount paid to distributor

//Desired output formatting for numbers
cout << setprecision(2) << fixed << showpoint;

//Prompt the user for the movies name
cout << "Please enter name of movie:" << endl;
cin >> movie;
cin.clear();
cin.ignore(256, '\n');

//Get adult tickets sold
cout << "Enter number of adult tickets sold: \n";
cin >> adult;

//Get child tickets sold
cout << "Enter number of child tickets sold: \n";
cin >> child;

//Calculate gross amount for adult tickets sold
gross_adult_ticket = adult * cost_per_adult_ticket;

//Calculate gross amount of child tickets sold
gross_child_ticket = child * cost_per_child_ticket;

//Calculate gross box office profit
total_box_office_profit = gross_child_ticket + gross_adult_ticket;

//Calculate net box office profit (Theater earnings)
net_box_office_profit = total_box_office_profit * .20;

//calculate amount paid to distributor
amount_paid_distributor = total_box_office_profit - net_box_office_profit;

//Display movie name
cout << "Movie Name: " << movie << endl;

//Display amount of adult tickets sold
cout << "Adult tickets sold: " << adult << endl;

//Display amount of child tickets sold
cout << "Child tickets sold: " << child << endl;

//Display gross amount for box office profit
cout << "Gross box office profit: " << total_box_office_profit << endl;

//Display net gross amount of profit
cout << "Gross net box office profit: " << net_box_office_profit << endl;

//Display amount paid to distributor
cout << "Amount paid to distributor: " << amount_paid_distributor << endl;

system("pause");


return 0;


This is my code. Everything seems to work properly except the output for nanme is some really long number.

Example output:

Movie Name: -02559631349317830000000000000000000000000000000000000.00
Adult tickets sold: 100.00
Child tickets sold: 200.00
Gross box office profit: 1000.00
Net box office profit: 200.00
Amount paid to distributor: 800.00
You have declared movie as a double.
Last edited on
Okay, I changed to to a string however now I am receiving an error. Sorry I am a beginner, not really sure how to fix it. All help is appreciated.
What error? It would be helpful if you posted the exact text of the error.

Did you include the <string> header?

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
Last edited on
closed account (iN6fizwU)
The line
#include <cstdlib>
may be needed at the start to use system("pause");

You also need a closing brace
}
at the end.
Topic archived. No new replies allowed.