Cinema Ticket

08:45 0 Comments A+ a-

Problem:
A movie in a local theater is in great demand. To help a local charity, the theater owner has decided to donate to the charity a portion of the gross amount generated from the movie. Write a program which takes input from user the movie name, adult ticket price, child ticket price, number of adult tickets sold, number of child tickets sold, and percentage of the gross amount to be donated to the charity.
The output of the program is as follows.
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Movie Name: ................................... Journey to Mars
Number of Tickets Sold: .................... 2650
Gross Amount: ................................. $ 9150.00
Percentage of Gross Amount Donated: 10.00%
Amount Donated: ............................. $ 915.00
Net Sale: ......................................... $ 8235.00
Note that the strings, such as "Movie Name:” in the first column are left-justified, the numbers in the right column are right-justified, and the decimal numbers are output with two decimal places.
Solution:
# include <iostream>
# include <iomanip>
using namespace std;
int main()
{
char movieName[50]; //Movie name intialized 
double adultTicketPrice; //Adult Ticket Price intialized
double childTicketPrice; //Children Ticket Price Initialized 
int adultTicketsSold; //Number of Adult tickets sold intialzed 
int childTicketSold; //Number of Children tickets sold intialzed
double perOfGrossAmountDonated; //Percentage of Gross Amount to be Donated Initialized
int numOfTicketsSold; //Total Number of Tickets Sold Initialized
double grossAmount; //Gross Ammount to be calculated intialized
double amountDonated; //Amount to be donated initialized
double netSale; //Net Sale After Donating Ammount from Gross Amount initialized
int i=0; //i is taken as a counter to print staric and upper design
cout << "Enter the Movie Name:" << endl;
cin.getline(movieName,50); //Movie Name Declared
cout << "Enter the Price of Adult Ticket (in $):" << endl;
cin >> adultTicketPrice; //Adult Ticket Price Declared in Dollars
cout << "Enter the Price of Child Ticket (in $):" << endl;
cin >> childTicketPrice; //Children Ticket Price Declared in Dollars
cout << "Enter the Number 0f Adult Tickets Sold:"<< endl;
cin >> adultTicketsSold; //Number of Adults Tickets sold declared
cout << "Enter the Number 0f Child Tickets Sold:" << endl;
cin >> childTicketSold; //Number of Children Tickets sold declared
cout << "Enter the Percentage of Gross Amount to be Donated:" << endl;
cin >> perOfGrossAmountDonated; //Percentage of Gross Amount to be Donated declared

numOfTicketsSold = adultTicketsSold + childTicketSold; //Number of total tickets sold clculated
grossAmount = (adultTicketPrice*adultTicketsSold) + (childTicketPrice*childTicketSold); //Gross Amount Earned Calculated
amountDonated = (grossAmount*perOfGrossAmountDonated) / 100; //Amount Donated Calculated
netSale = grossAmount - amountDonated; //Net Sale Calculated

while (i < 28){
cout << "_" << "*"; //Upper Design Printed
i++;
}
cout << endl;
cout << "Movie Name:" << "........................" <<setw(15)<< movieName << endl; //Movie Name Displayed
cout << "Number of Tickets Sold:" << "............" <<setw(15)<< numOfTicketsSold << endl; //Number of Tickets Sold Displayed 
cout << "Gross Amount:" << "......................" <<"$"<< setprecision(2) << fixed <<setw(14)<< grossAmount << endl; //Gross Amount Collected Displayed, Set precision taken 14 due to a $ sign
cout << "Percentage of Gross Amount Donated:"<<setw(14)<< setprecision(2) << fixed << perOfGrossAmountDonated <<"%"<< endl; //Percentage of Gross Amount Donated Displayed
cout << "Amount Donted:" << "....................." <<"$"<< setprecision(2)<< fixed  <<setw(14)<< amountDonated << endl; //Amount Donated Displayed
cout << "Net Sale:" << ".........................." << "$"<< setprecision(2) << fixed <<setw(14)<< netSale << endl; //Net Sale Displayed





system("pause");
return 0;

}