In: Computer Science
Problem #4 – Logical Operators: Movie Ticket Price
The local movie theater in town has a ticket price of $12.00.
But, if you are a senior (55 and older), or are under 10, or are seeing a matinee which screens from 3 pm to 5 pm, you get the discounted price of $7.00, nice!
Hint 1: "55 and older" is INCLUSIVE
Hint 2: under 10 is EXCLUSIVE
Hint 3: the range 3 to 5 is INCLUSIVE
Hint 4: limit 1 per patron (i.e., it doesn’t compound)
Hint 5: considering there’s 3 am and pm and 5 am and pm, using a 24-hour clock (aka military time) may be an easier option (0000 to 2359)
Determine which of the two prices the customer is eligible for.
Givens:
Time of Movie (Assume whole numbers here)
Age of the customer
Result To Print Out:
"The ticket price is X"
Must use C# coding using conditional statements
Code-
using System;
class MainClass
{
static public void Main(string[] args)
{
int age,time;
Console.Write("Enter your age");
age=int.Parse(Console.ReadLine());//reading int input
Console.Write("Enter the time");
time=int.Parse(Console.ReadLine());//reading int input
if(age>=55 || age<10 || (time>=1500 && time<=1700))//Or,and operations used accordingly
Console.Write("The ticket price is $"+7);
else
Console.Write("The ticket price is $"+12);
}
}
Indenatation-
Output-