fork(1) download
  1. // Nicolas Ruano CS1A Chapter 3 Pp.143-144 #5
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <string>
  5. using namespace std;
  6.  
  7. int main() {
  8. const double ADULT_TICKET_PRICE = 6.00;
  9. const double CHILD_TICKET_PRICE = 3.00;
  10. const double THEATER_PERCENT = 0.20; // 20% goes to theater
  11.  
  12. string movieName;
  13. int adultTickets, childTickets;
  14. double grossProfit, netProfit, distributorAmount;
  15.  
  16. // Input
  17. cout << "Enter the name of the movie: Wheels of Fury\n";
  18. getline(cin, movieName); // Use getline for movie names with spaces
  19.  
  20. cout << "Enter the number of adult tickets sold: 382\n";
  21. cin >> adultTickets;
  22.  
  23. cout << "Enter the number of child tickets sold: 127\n";
  24. cin >> childTickets;
  25.  
  26. // Calculations
  27. grossProfit = (adultTickets * ADULT_TICKET_PRICE) + (childTickets * CHILD_TICKET_PRICE);
  28. netProfit = grossProfit * THEATER_PERCENT;
  29. distributorAmount = grossProfit - netProfit;
  30.  
  31. // Output formatted report
  32. cout << fixed << setprecision(2);
  33. cout << "\nMovie Name: Wheels of Fury" << movieName << endl;
  34. cout << "Adult Tickets Sold: 382" << adultTickets << endl;
  35. cout << "Child Tickets Sold: 127" << childTickets << endl;
  36. cout << "Gross Box Office Profit: $2673.00" << grossProfit << endl;
  37. cout << "Net Box Office Profit: $534.60" << netProfit << endl;
  38. cout << "Amount Paid to Distributor: $2138.40" << distributorAmount << endl;
  39.  
  40. return 0;
  41. }
  42.  
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
Enter the name of the movie: Wheels of Fury
Enter the number of adult tickets sold: 382
Enter the number of child tickets sold: 127

Movie Name: Wheels of Fury
Adult Tickets Sold: 3822
Child Tickets Sold: 1270
Gross Box Office Profit: $2673.0012.00
Net Box Office Profit: $534.602.40
Amount Paid to Distributor: $2138.409.60