Problem: A movie theater only keeps a percentage of the revenue earned from ticket sales. The
remainder goes to the movie distributor. Write a program that calculates a theater’s
gross and net box office profit for a night. The program should ask for the name of the
movie, and how many adult and child tickets were sold. (The price of an adult ticket is
$10.00 and a child’s ticket is $6.00.) It should display a report similar to
Movie Name: “Wheels of Fury”
Adult Tickets Sold: 382
Child Tickets Sold: 127
Gross Box Office Profit: $ 4582.00
Net Box Office Profit: $ 916.40
Amount Paid to Distributor: $ 3665.60
--------------------------------
I have the basic concept down actually, and my output is correct. My only issue is with regards to the "setw" stuff. I find it really annoying I need to match it perfectly, but I was wondering just for the part on the "SETW" if I did it correct.
Also, in some other programs that were similar to the ones I saw doing, they put "SETW(10)" lets say, with "Right" or "Left". I am confused why they even needs to do this, I just used SETW and it came out correct. Do I need to use both? Or is my program fine the way it is and I am over-thinking it. Thanks a bunch. :)
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
|
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
double gross;
double box_Office_Profit;
double Amount_Paid_To_Distributor;
string Movie_Name;
double adult_Tickets;
double child_Tickets;
const double Adult_Ticket_Price = 10.00;
const double child_Ticket_Price = 6.00;
const double PERCENT_PROFIT = .20;
cout << "What is the name of the movie you wish to see?";;
getline(cin, Movie_Name);
cout << "How many adult tickets were sold? ";
cin >> adult_Tickets;
cin.ignore();
cout << "How many child tickets were sold? ";
cin >> child_Tickets;
cin.ignore();
adult_Tickets *= Adult_Ticket_Price;
child_Tickets *= child_Ticket_Price;
gross = (adult_Tickets + child_Tickets);
box_Office_Profit = (gross * PERCENT_PROFIT);
Amount_Paid_To_Distributor = gross - box_Office_Profit;
cout << setprecision(2) << showpoint << fixed;
cout << "Movie Name: " << setw(35) << Movie_Name << endl;
cout << "Adult Tickets Sold: " << setw(25) << adult_Tickets << endl;
cout << "Child Tickets Sold: " << setw(25) << child_Tickets << endl;
cout << "Gross Box Office Profit: " << setw(15) << "$" << gross << endl;
cout << "Net Box Office Profit: " << setw(17) << "$" << box_Office_Profit << endl;
cout << "Amount Paid to Distributor: " << setw(12) << "$" << Amount_Paid_To_Distributor << endl;
return 0;
}
|