Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assignment: Create a Java program that effectively calculates and displays the ticket booking information based on the number of adult and child tickets entered by
Assignment:
Create a Java program that effectively calculates and displays the ticket booking information based on
the number of adult and child tickets entered by the user. It also considers discounts for both adult and
child tickets, applying them when the respective thresholds are reached. The final cost and discount
information are displayed to the user.
Input for Adult Tickets:
The program prompts the user to enter the number of adult tickets they want to purchase.
It checks if the entered value is a valid nonnegative integer. If not, it prints an error message and sets
the Boolean variable to false.
Calculating Total Cost for Adults: ADULT TICKET PRICE is $
If the entered number of adult tickets is valid, it calculates the total cost for adult tickets
Applying Adult Discount: Adult discount is that is
If the number of adult tickets exceeds the discount threshold or more, it calculates the discount
amount for adults
It subtracts the discount amount from the total cost for adults.
Displaying Ticket Booking Summary for Adults:
It displays the ticket booking summary for adults, including the number of adult tickets and the total cost
for adults, rounded to two decimal places use the variable for adults ticket
Input for Child Tickets:
The program prompts the user to enter the number of child tickets they want to purchase.
It checks if the entered value is a valid nonnegative integer. If not, it prints an error message and sets
Boolean variable to false.
Calculating Total Cost for Children: CHILD TICKET PRICE is $
If the entered number of child tickets is valid, it calculates the total cost for child tickets
Applying Child Discount: Child Discount is that is
If the number of child tickets exceeds the discount threshold which is or more, it calculates the
discount amount for children.
It subtracts the discount amount from the total cost for children.
Displaying Ticket Booking Summary for Children:
It displays the ticket booking summary for children, including the number of child tickets and the total
cost for children, rounded to two decimal places use the variable for children tickets
Calculating Total Discount Amount and Total Cost:
It calculates the total discount amount by adding the discount amounts for adults and children.
It calculates the overall total cost by adding the total cost for adults and children.
Displaying Final Information:
It prints the total discount amount received by the customer.
It prints the total cost that the customer needs to pay, rounded to two decimal pla
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started