Answered step by step
Verified Expert Solution
Link Copied!

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.
1- 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 non-negative integer. If not, it prints an error message and sets
the Boolean variable to false.
2- Calculating Total Cost for Adults: ADULT TICKET PRICE is $12.5
If the entered number of adult tickets is valid, it calculates the total cost for adult tickets
3- Applying Adult Discount: Adult discount is 15% that is .15
If the number of adult tickets exceeds the discount threshold 5 or more, it calculates the discount
amount for adults
It subtracts the discount amount from the total cost for adults.
4- 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*100.0)/100.0
5- 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 non-negative integer. If not, it prints an error message and sets
Boolean variable to false.
6- Calculating Total Cost for Children: CHILD TICKET PRICE is $8.0
If the entered number of child tickets is valid, it calculates the total cost for child tickets
7- Applying Child Discount: Child Discount is 10% that is .1
If the number of child tickets exceeds the discount threshold which is 3 or more, it calculates the
discount amount for children.
It subtracts the discount amount from the total cost for children.
8- 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*100.0)/100.0
9- 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.
10- 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 places.Sample Run:
Enter the number of adult tickets you want to purchase: 6
Adult Discount Applied: $11.25
Ticket Booking Summary:
Number of Adult Tickets: 6
Total Cost for Adults: $63.75
Enter the number of child tickets you want to purchase: 5
Child Discount Applied: $4.0
Ticket Booking Summary:
Number of Child Tickets: 5
Total Cost for Children: 36.0
You received a discount amount of $15.25
Total Cost that you need to pay is: $99.75
Press any key to continue ...
Sample Run:
Enter the number of adult tickets you want to purchase: 6
Adult Discount Applied: $11.25
Ticket Booking Summary:
Number of Adult Tickets: 6
Total Cost for Adults: $63.75
Enter the number of child tickets you want to purchase: -4
Error:This is not a valid number of child tickets.
Thank you for your business...
You received a discount amount of $11.25
Total Cost that you need to pay is: $63.75
Press any key to continue...

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

1. Why do people tell lies on their CVs?

Answered: 1 week ago

Question

2. What is the difference between an embellishment and a lie?

Answered: 1 week ago