Velan resort decides to automate their bookings. By automating they can easily enter the customer details, number of people visiting the resort, and based on the customer category they can calculate the booking price. So help the resort to do the automation using a Java programAssumptionPrice is in dollarsFor 1 adult 1000 per dayFor 1 child 650 per dayTake input from the user as a single string separating each field with a colon. <customer name>:<number of adults>:<number of child>:<number of days>Note:Customer category should be either "adult" or "child".If the number of adults is less than zero, print "Invalid input for number of adults"If the number of children is less than zero, print "Invalid input for number of children"If the number of days is less than or equal to zero, print "Invalid input for number of days"In the Sample Input / Output provided, the highlighted text in bold corresponds to the input given by the user, and the rest of the text represents the output.Ensure to follow the object-oriented specifications provided in the question description.Ensure to provide the names for classes, attributes, and methods as specified in the question description.Adhere to the code template, if provided.Do not use System.exit(0) to terminate the programSample Input/Output 1:Enter the customer detailsHarish:2:2:2Harish your booking is confirmed and the total cost is 6600Sample Input/Output 2:Enter the customer detailsGuru:1:0:0Invalid input for number of daysSample Input/Output 3:Ezhil:1:0:1Ezhil your booking is confirmed and the total cost is 1000
Question
Velan resort decides to automate their bookings. By automating they can easily enter the customer details, number of people visiting the resort, and based on the customer category they can calculate the booking price. So help the resort to do the automation using a Java programAssumptionPrice is in dollarsFor 1 adult 1000 per dayFor 1 child 650 per dayTake input from the user as a single string separating each field with a colon. <customer name>:<number of adults>:<number of child>:<number of days>Note:Customer category should be either "adult" or "child".If the number of adults is less than zero, print "Invalid input for number of adults"If the number of children is less than zero, print "Invalid input for number of children"If the number of days is less than or equal to zero, print "Invalid input for number of days"In the Sample Input / Output provided, the highlighted text in bold corresponds to the input given by the user, and the rest of the text represents the output.Ensure to follow the object-oriented specifications provided in the question description.Ensure to provide the names for classes, attributes, and methods as specified in the question description.Adhere to the code template, if provided.Do not use System.exit(0) to terminate the programSample Input/Output 1:Enter the customer detailsHarish:2:2:2Harish your booking is confirmed and the total cost is 6600Sample Input/Output 2:Enter the customer detailsGuru:1:0:0Invalid input for number of daysSample Input/Output 3:Ezhil:1:0:1Ezhil your booking is confirmed and the total cost is 1000
Solution
To solve this problem, you can create a Java program that uses a class to represent the booking details. Here's a step-by-step guide on how to do it:
Step 1: Define a class named Booking with the following attributes: customerName, numAdults, numChildren, and numDays.
public class Booking {
private String customerName;
private int numAdults;
private int numChildren;
private int numDays;
//...
}
Step 2: Create a constructor for the Booking class that takes the customer name, number of adults, number of children, and number of days as parameters.
public Booking(String customerName, int numAdults, int numChildren, int numDays) {
this.customerName = customerName;
this.numAdults = numAdults;
this.numChildren = numChildren;
this.numDays = numDays;
}
Step 3: Define a method calculatePrice() in the Booking class that calculates the total cost based on the number of adults, children, and days. The cost for an adult is 650 per day.
public int calculatePrice() {
return (numAdults * 1000 + numChildren * 650) * numDays;
}
Step 4: In the main method, take the input from the user as a single string. Split the string using the colon as the delimiter to get the customer name, number of adults, children, and days.
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
String[] details = input.split(":");
//...
}
Step 5: Create a Booking object using the details obtained from the user input. Before creating the object, validate the input for the number of adults, children, and days. If any of these values
Similar Questions
Develop a Java program for a ticket pricing system. Prompt the user to enter their age and the type of ticket they want to purchase (1 for regular, 2 for VIP). Use if-then-else statements to calculate the ticket price based on the following criteria:Regular Ticket Prices:Age 0-5: FreeAge 6-12: $10Age 13-18: $15Age 19 and above: $20VIP Ticket Prices:Age 0-5: $5Age 6-12: $15Age 13-18: $20Age 19 and above: $30Display the calculated ticket price to the user. Ensure that your program handles invalid input, such as negative age or an invalid ticket type.
The theatre wants to collect the names of all audience who visit the theatre and calculate the total amount collected as fare for the tickets from the audience. Write a Java program
Consider a ticket reservation system that allows users to book tickets for various destinations. Each ticket has details such as passenger name, destination, ticket price, and passenger age. The ticket prices are calculated based on the passenger's age, with children (age <= 12) receiving a 50% discount, senior citizens (age >= 60) receiving a 30% discount, and others paying the regular price. The system also tracks the confirmation status of each ticket.Design a Java program that implements this ticket reservation system. The program should prompt the user to input details for multiple tickets, including passenger name, destination, ticket price, and passenger age. It should then calculate and display the total amount of tickets booked for confirmed tickets alone, considering the discounted prices based on passenger age.Write the Java code for the ticket reservation system and demonstrate its functionality with a sample input/output scenario.Sample Input: 3 //No of tickets to book Ravi // NameDelhi // Destination2000 // Price70 // Age Manu // NameDelhi // Destination2000 // Price9 // Age Priya // NameDelhi // Destination2000 // Price40 // Ageconfirm // Do you want to confirm or cancel ticket 1? (confirm/cancel)cancel // Do you want to confirm or cancel this ticket 2? (confirm/cancel)confirm // Do you want to confirm or cancel this ticket 3? (confirm/cancel)Sample Output:3400.0 // Total Amount of Confirmed Tickets
For a movie ticket booking system, write a program in Java to implement the process. Some persons need First class seating system (Option1). Another option is Second class seating system (Option 2). Implement this process using Polymorphism and inheritance. In the ‘First’ class get the inputs like movie name, Theater Name, Show Date, and Number of Seats. If the date is 2022-11-20 print the price as 500 else print the price as 1000 for each seat. In the ‘Second’ class Get the inputs like movie name, Theater Name, Show Date, and Number of Seats. Cost of each ticket is Rs.200. If theater name is “mnbjhrbjbj” apply coupon code and reduce Rs.500 from actual price. Print all the details as a report.
In a theatre four types of audience come to watch movies. They are,1. Singles2. Couples3. A set of parents + 1 kid4. A set of parents + 2 kidThe theatre ticket rate for any audience group as follows: 1st person in the group -Rs.400/- 2nd person in the group -Rs.300/- 3rd person in the group -Rs.200/- 4th person in the group -Rs.100/-The theatre wants to collect the names of all audience who visit the theatre and calculate the total amount collected as fare for the tickets from the audience. Write a Java program that implements the above
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.