In a theatre four types of audience come to watch movies. They are, 1. Singles 2. Couples 3. A set of parents + 1 kid 4. A set of parents + 2 kid The 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 using the concept of Constructor Overloading (Polymorphism). Input 1: Enter the total number of audience group : 2 Enter the group category: 1 Enter name of first person: Kaushik Enter the group category: 3 Enter name of first person: Ashmi Enter name of second person: Krish Enter name of third person: Mahi Output 1 The audience names are Kaushik Ashmi Krish Mahi The total amount collected: 1300 Input 2: Enter the total number of audience group : 3 Enter the group category: 1 Enter name of first person: Kaushik Enter the group category: 3 Enter name of first person: Ashmi Enter name of second person: Krish Enter name of third person: Mahi Enter the group category: 4 Enter name of first person: Rashmi Enter name of second person: Rakesh Enter name of third person: Jesi Enter name of fourth person: Meha Output 2 The audience names are Kaushik Ashmi Krish Mahi Rashmi Rakesh Jesi Meha The total amount collected: 2300
Question
In a theatre four types of audience come to watch movies. They are,
-
Singles -
Couples -
A set of parents + 1 kid -
A set of parents + 2 kid
The 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 using the concept of Constructor Overloading (Polymorphism).
Input 1:
Enter the total number of audience group : 2
Enter the group category: 1
Enter name of first person: Kaushik
Enter the group category: 3
Enter name of first person: Ashmi
Enter name of second person: Krish
Enter name of third person: Mahi
Output 1
The audience names are
Kaushik
Ashmi
Krish
Mahi
The total amount collected: 1300
Input 2:
Enter the total number of audience group : 3
Enter the group category: 1
Enter name of first person: Kaushik
Enter the group category: 3
Enter name of first person: Ashmi
Enter name of second person: Krish
Enter name of third person: Mahi
Enter the group category: 4
Enter name of first person: Rashmi
Enter name of second person: Rakesh
Enter name of third person: Jesi
Enter name of fourth person: Meha
Output 2
The audience names are
Kaushik
Ashmi
Krish
Mahi
Rashmi
Rakesh
Jesi
Meha
The total amount collected: 2300
Solution
This problem can be solved using Java programming language. Here is a step by step guide on how to solve it:
Step 1: Create a class named AudienceGroup with the following attributes: groupCategory, names and totalAmount. The names attribute should be an ArrayList of Strings to store the names of the audience.
Step 2: Create four constructors in the AudienceGroup class, each representing a different group category. Each constructor should take the group category and the names of the audience as parameters. The constructors should also calculate the total amount based on the group category and add it to the totalAmount attribute.
Step 3: Create a method named getNames in the AudienceGroup class that returns the names of the audience in the group.
Step 4: Create a method named getTotalAmount in the AudienceGroup class that returns the total amount collected from the group.
Step 5: In the main method, create an ArrayList of AudienceGroup objects. Then, ask the user to enter the total number of audience groups and for each group, ask the user to enter the group category and the names of the audience. Create a new AudienceGroup object with the entered data and add it to the ArrayList.
Step 6: After all the groups have been entered, iterate over the ArrayList and call the getNames and getTotalAmount methods on each AudienceGroup object to print the names of the audience and the total amount collected.
This is a basic outline of how you can solve this problem. You may need to adjust it based on your specific requirements and constraints.
Similar Questions
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 using the concept of Constructor Overloading (Polymorphism).
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.
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
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.
In ABC movie theatre, adult ticket was Rs.300 and child ticket was Rs.150. To watch a movie, there were 90 individuals including children and adults. If the total income of the cinema hall was Rs. 22500, find the number of adults in the movie theatre.
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.