fork(1) download
  1. // Nicolas Ruano CS1A Chapter 3 Pp.143-144 #5
  2. /*******************************************************************************
  3.  * BOX OFFICE SOLVING
  4.  * ____________________________________________________________________________
  5.  * In this program, we are trying to figure out and understand how many tickets
  6.  * and the box office of the film. Piece by piece, it is broken down in
  7.  * sequencial steps for solving the probllem
  8.  * ____________________________________________________________________________
  9.  * INPUT of what we have so far
  10.  * The Price of Adult Tickets (adultTickets) = 6.00
  11.  * The price of Child Tickets (childTickets) = 3.00
  12.  * The theater percent = 0.20 -> which is 20%
  13.  *
  14.  * The number of Adult Tickets being sold = 382
  15.  * The number of Child Tickets being sold = 127
  16.  * ____________________________________________________________________________
  17.  * OUTPUT for displaying
  18.  * Name of the film: Wheels of Fury
  19.  * Adult Tickets sold = 382
  20.  * Child Tickets sold = 127
  21.  * The gross Box Office profit = $2673.00
  22.  * Net Box Office Profit = $534.00
  23.  * Amount Paid to Distributor: $2138.40
  24. *******************************************************************************/
  25. #include <iostream>
  26. #include <iomanip>
  27. #include <string>
  28. using namespace std;
  29.  
  30. int main() {
  31. const double ADULT_TICKET_PRICE = 6.00;
  32. const double CHILD_TICKET_PRICE = 3.00;
  33. const double THEATER_PERCENT = 0.20; // 20% goes to theater
  34.  
  35. string movieName;
  36. int adultTickets, childTickets;
  37. double grossProfit, netProfit, distributorAmount;
  38.  
  39. // Input
  40. cout << "Enter the name of the movie: Wheels of Fury\n ";
  41. getline(cin, movieName);
  42.  
  43. cout << "Enter the number of adult tickets sold: ";
  44. cin >> adultTickets;
  45.  
  46. cout << "Enter the number of child tickets sold: ";
  47. cin >> childTickets;
  48.  
  49. // Calculations
  50. grossProfit = (adultTickets * ADULT_TICKET_PRICE) + (childTickets * CHILD_TICKET_PRICE);
  51. netProfit = grossProfit * THEATER_PERCENT;
  52. distributorAmount = grossProfit - netProfit;
  53.  
  54. // Output formatted report
  55. cout << fixed << setprecision(2);
  56. cout << "\nMovie Name: Wheels of Fury " << movieName << endl;
  57. cout << "Adult Tickets Sold: " << adultTickets << endl;
  58. cout << "Child Tickets Sold: " << childTickets << endl;
  59. cout << "Gross Box Office Profit: $" << grossProfit << endl;
  60. cout << "Net Box Office Profit: $" << netProfit << endl;
  61. cout << "Amount Paid to Distributor: $" << distributorAmount << endl;
  62.  
  63. return 0;
  64. }
  65.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Enter the name of the movie: Wheels of Fury
 Enter the number of adult tickets sold: Enter the number of child tickets sold: 
Movie Name: Wheels of Fury 
Adult Tickets Sold: 2
Child Tickets Sold: 0
Gross Box Office Profit: $12.00
Net Box Office Profit: $2.40
Amount Paid to Distributor: $9.60