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
PLEASE USE C++
The percentage of amount to be donated to charity can be calculate as :
donation_amount = percentage * (adult_price * adult_ticket + child_price * child_ticket) / 100
The c++ code for the given problem is:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string movie;
int adult_price, child_price, adult_ticket, child_ticket, charity;
cout<<"Enter movie name : ";
cin>>movie;
cout<<"\nEnter number of adult tickets sold : ";
cin>>adult_ticket;
cout<<"\nEnter number of child tickets sold : ";
cin>>child_ticket;
cout<<"\nEnter price of adult tickets : ";
cin>>adult_price;
cout<<"\nEnter price of child tickets : ";
cin>>child_price;
cout<<"\nEnter the percentage of total to be donated to charity : ";
cin>>charity;
int donation_amount = charity * (adult_price * adult_ticket + child_price * child_ticket) / 100;
cout<<"\nThe amount to be donated to charity is : "<<donation_amount;
return 0;
}