In: Computer Science
c++120
Holideals at the Movies!
We have special movie tickets on holidays! Prices are discounted when you buy a pair of tickets.
Create a program for the HoliDeals event that computes the subtotal for a pair of tickets. The program should ask the the ages of the first and second guests to compute the price.
There are different pricing structures based on the guests' age.
Children tickets cost $10 (age below 13)
Young Adult tickets cost $13 (age below 21)
Adult tickets cost $15 (age below 65)
Senior tickets cost $10 (age 65 and over)
To simplify the problem, let's assume that parents/guardians will always accompany pairs of children who will watch a movie.
The pricing structure should be displayed to the user. Please see the sample output below to guide the design of your program.
Welcome to HoliDeals at the Movies! Tickets tonight can only be bought in pairs. Here are our movie ticket deals: Children - $10.00 Young Adults - $13.00 Adults - $15.00 Seniors - $10.00 Please enter the age of the person for the first guest: 15 Please enter the age of the person for the second guest: 16 The Subtotal for the ticket cost is: $26.00.
Q2:
Salary Calculator
Create a program that computes the salary based on an employee's hourly wage and hours worked. Use the following formulas:
Less than or equal to 40 hours worked
hourly wage * hours worked
Over 40, but less than or equal to 65 hours worked
(hourly wage * 40) + (hours worked - 40) * (hourly wage * 1.5)
Over 65 hours worked
(hourly wage * 40) + (hourly wage * 1.5) * 25 + (hours worked - 65) * hourly wage * 2
Please see the sample output below to guide the design of your program.
Hourly wage: 12 Hours worked: 20 Total Salary Owed: $240.00
Q1)
Here is your code..
#include<iostream>
#include <iomanip>
using namespace std;
int main()
{
float price,total_price=0;
int persons=1,age;
cout<<"Welcome to HoliDeals at the Movies!"
<<endl;
cout<<"Tickets tonight can only be bought in
pairs." <<endl;
cout<<"Here are our movie ticket deals:"
<<endl;
cout<<endl;
cout<< "Children - $10.00" <<endl;
cout<<"Young Adults - $13.00"<<endl;
cout<<"Adults - $15.00"<<endl;
cout<<"Seniors - $10.00"<<endl;
cout<<endl;
while (persons<=2) {
if(persons!=1){
cout <<
"Please enter the age of the person for the second guest: ";
} else {
cout <<
"Please enter the age of the person for the first guest: ";
}
cin >> age;
{
if (age < 13)
price = 10.00;
else if (age>=13 && age < 21)
price = 13.00;
else if (age>=21 && age<65)
price = 15.00;
else
price = 10.00;
}
total_price = price + total_price;
persons++;
}
cout << fixed;
cout << setprecision(2);
cout << "The Subtotal for the ticket cost is: $
" << total_price;
return 0;
}
Q2)
Here is your code...
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
float Hwage,TotalSalary;
int Hworked;
cout<<"Hourly wage: ";
cin>>Hwage;
cout<<"Hours worked: ";
cin>>Hworked;
if(Hworked<=40)
{
TotalSalary = Hworked *
Hwage;
}
else if (Hworked>40 && Hworked
<=65)
{
TotalSalary = (Hwage * 40) +
(Hworked - 40) * (Hwage * 1.5);
}
else
{
(Hwage * 40) + (Hwage * 1.5) * 25 +
(Hworked - 65) * Hwage * 2;
}
cout << fixed;
cout << setprecision(2);
cout<<"Total Salary Owed : $
"<<TotalSalary;
return 0;
}