Write a program that determines the price of a movie ticket (similar to the one in the chapter). The program asks for the customer's age and for the time on a 24-hour clock (where noon is 1200 and 4:30PM is 1630). The normal adult ticket price is $8.00, however the adult matinee price is $5.00. Adults are those over 13 years. The normal children's ticket price is $4.00, however the children's matinee price is $2.00. Assume that a matinee starts at any time earlier than 5pm (1700).

Respuesta :

Answer:

#include <iostream>

using namespace std;

int main() {

int age,time;

float price;

cout<<"Enter age:";

cin>>age;

cout<<"Enter time(in 24 hour clock for noon 1200):";

cin>>time;

if(age>13){

if(time<1700){

price=5;

}else{

price=8;

}

}else{

if(time<1700){

price=2;

}else{

price=4;

}

}

cout<<"Price: $"<<price<<endl;

}

Explanation:

Okay, here are the steps to be taken in order to be able to Write a program that determines the price of a movie ticket as given in details in the question above. Therefore, checked the steps below;

==> Input the age and the time.

==> If the age is not greater than 13, input the time(that is <1700) and follow it by imputing the price.

And if the age is greater than 13, you will also need to input the price. Just as below;

#include <iostream>

using namespace std;

int main() {

int age,time;

float price;

cout<<"Enter age:";

cin>>age;

cout<<"Enter time(in 24 hour clock for noon 1200):";

cin>>time;

if(age>13){

if(time<1700){

price=5;

}else{

price=8;

}

}else{

if(time<1700){

price=2;

}else{

price=4;

}

}

cout<<"Price: $"<<price<<endl;

}

The program is an illustration of conditional statements

Conditional statements are statements used to make decisions

The program written in C++ where comments are used to explain each line is as follows:

#include <iostream>

using namespace std;

int main() {

   //This declares the variables

   int age,ttime;    float price;

   //This gets input for age

   cout<<"Age:"; cin>>age;

   //This gets input for time

   cout<<"Time(in 24 hour clock):"; cin>>ttime;

   //Age greater than 13 are considered as adults

   if(age>13){

       //This determines the matinee ticket price

       if(ttime<1700){

           price=5;

       }

       //This determines the normal ticket price

       else{

           price=8;

       }

   }

   //For children

   else{

       //This determines the matinee ticket price

       if(time<1700){

           price=2;

       }

       //This determines the normal ticket price

       else{

           price=4;

       }

   }

   //This prints the ticket price

   cout<<"Ticket price: $"<<price<<endl;

   return 0;

}

Read more about conditional statements at:

https://brainly.com/question/24833629