We first import the header file for input output using include.
#include <iostream>
Next, we import the namespace for input output.
using namespace std;
We first declare and initialize variables for all the information that needs to be stored and displayed.
We take float data type since revenues earned by theater and distributor are shown as a percentage of the total sales made.
float adultFee = 10, childFee = 6, adultTickets, childTickets;
float sales, tRev, dRev;
The user is prompted to enter the number of tickets for both adults and children.
cout<<"Enter the number of adult tickets "<<endl;
cin >> adultTickets;
cout<<"Enter the number of child tickets "<<endl;
cin >> childTickets;
Following the input from the user, total sales, the earnings of both the theater and the distributor are calculated.
total sales made by the theater
sales = (adultFee * adultTickets) + (childFee * childTickets);
total revenue earned by the theater
tRev = (0.2 * sales);
total revenue earned by the distributor
dRev = (sales - tRev);
As a last step, total sales, theater revenue and distributors profit are displayed.
All the steps shown above are put down and the program is shown below.
int main()
{
float adultFee = 10, childFee = 6, adultTickets, childTickets;
float sales, tRev, dRev;
cout<<"Enter the number of adult tickets "<<endl;
cin >> adultTickets;
cout<<"Enter the number of child tickets "<<endl;
cin >> childTickets;
// total sales made by the theater
sales = (adultFee * adultTickets) + (childFee * childTickets);
// total revenue earned by the theater
tRev = (0.2 * sales);
// total revenue earned by the distributor
dRev = (sales - tRev);
cout<<"Total sales made by the theater $" << sales << endl;
cout<<"Total revenue earned by the theater $" << tRev << endl;
cout<<"Total revenue earned by the distributor $" << dRev << endl;
}