# Chapter 3 – #7: Box Office – Tony Gaddis – Starting Out With C++

## >_ 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”
Child Tickets Sold:                                              127
Gross Box Office Profit:                      \$ 4582.00
Net Box Office Profit:                           \$     916.40
Amount Paid to Distributor:              \$ 3665.60

NOTE: Assume the theater keeps 20 percent of the gross box office profit.

## >_ Solution

``````#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
// Constant variables
CHILD_PRICE = 6,
PROFIT = .20;

string movie_name;

child_tkt;

float total,
theater_per;

cout << "\nWhat was the name of the movie? ";
getline(cin, movie_name);

cout << "\nHow many adult tickets? ";
cout << "How many child tickets? ";
cin >> child_tkt;

// Calculate gross and net profit
theater_per = total * PROFIT;

// Display report
cout << setprecision(2) << fixed;
cout << "\nMovie Name: \"";
cout << movie_name << '\"' <<endl;
cout << "Adult tickets sold:      " << setw(10);
cout << "\nChild tickets sold:      " << setw(10);
cout << child_tkt;
cout << "\nTotal cost:              " << setw(10);
cout << total;
cout << "\nGross Box Office Profit: " << setw(10);
cout << theater_per << '\n' <<endl;

// Terminate Program
return 0;
}``````

## >_ Video Walk Through

This video includes a step by step process of how I solve programming challenge #7.

## >_That’s it!

Thank you for taking interest in what I do! I hope it was helpful for you as much as it helped me along my journey in learning to code!