In: Computer Science
•A theater owner agrees to donate a portion of gross ticket sales to a charity
•The program will prompt the user to input:
−Movie name
−Adult ticket price
−Child ticket price
−Number of adult tickets sold
−Number of child tickets sold
−Percentage of gross amount to be donated
•Inputs: movie name, adult and child ticket price, # adult and child tickets sold, and percentage of the gross to be donated
•The program needs to:
1.Get the movie name
2.Get the price of an adult ticket price
3.Get the price of a child ticket price
4.Get the number of adult tickets sold
5.Get the number of child tickets sold
USE C++
#include <iostream>
using namespace std;
int main() {
string movieName;
double adultTicketPrice,childTicketPrice,
percentDonated;
int adultTickets,childTickets;
cout<<"Enter the movie name : ";
cin>>movieName;
cout<<"\nEnter adult ticket price : ";
cin>>adultTicketPrice;
cout<<"\nEnter child ticket price : ";
cin>>childTicketPrice;
cout<<"\nEnter the number of adult tickets sold
: ";
cin>>adultTickets;
cout<<"\nEnter the number of child tickets
sold : ";
cin>>childTickets;
cout<<"\nPercentage of gross amount to be
donated : ";
cin>>percentDonated;
double totalAmount = (adultTicketPrice*adultTickets +
childTicketPrice*childTickets)* percentDonated/100.00;
double donation = totalAmount*percentDonated;
cout<<" \nCharity amount =
$"<<donation;
return 0;
}
Output:
Enter the movie name : ToyStory4 Enter adult ticket price : 5.99 Enter child ticket price : 3.99 Enter the number of adult tickets sold : 120 Enter the number of child tickets sold : 210 Percentage of gross amount to be donated : 5 Charity amount = $389.175
Do ask if any doubt.