Knowee
Questions
Features
Study Tools

In an online movie ticket booking system book the tickets under 3 seat type categories. Seat type is categorized as 1. Normal 2. Executive 3.VIP. Get the details like seat type, name and with or without refreshments. If any other choice is given other than 3 for seat type exit the program. The ticket charge is collected based on the following criteria:Seat typeWith refreshments (Indicated as WR in program)Without refreshments(Indicated as W in program)Normal (Option 1)Rs.1500Rs.2000Executive (Option 2)Rs.1600Rs.2400VIP (Option 3)Rs.1800Rs.2800 Write a menu-driven program in Java to implement the ticket booking process. Implement this process by creating a base class ‘Ticket’ and child class ‘Calculation’  with method overriding and inheritance. Use the constructor for initializing the number of persons and the total cash collected. Find the total cash collected for all bookings and the count of total bookings. The program accepts any number of ticket bookings.Press any number>3 as input to seat type for quitting the program. InputGet the following details:Seat type (Integer)(1 or 2 or 3)Name (String)With/without Refreshments (String)(WR or W)Press number>3 to exitOutputPrint the following details:Count of total bookings (Integer)(Eg:Count: 2)(Print only once at the beginning before printing other outputs)Seat typeNameWith/without RefreshmentsCalculated fee for that particular booking (Integer)(Eg:Fees: 2400)..............(for any no.of booking)Total cash collected for all bookings (Integer)(Eg:Total Cash: 4200)(Print finally once only after printing all other outputs)

Question

In an online movie ticket booking system book the tickets under 3 seat type categories. Seat type is categorized as 1. Normal 2. Executive 3.VIP. Get the details like seat type, name and with or without refreshments. If any other choice is given other than 3 for seat type exit the program. The ticket charge is collected based on the following criteria:Seat typeWith refreshments (Indicated as WR in program)Without refreshments(Indicated as W in program)Normal (Option 1)Rs.1500Rs.2000Executive (Option 2)Rs.1600Rs.2400VIP (Option 3)Rs.1800Rs.2800 Write a menu-driven program in Java to implement the ticket booking process. Implement this process by creating a base class ‘Ticket’ and child class ‘Calculation’  with method overriding and inheritance. Use the constructor for initializing the number of persons and the total cash collected. Find the total cash collected for all bookings and the count of total bookings. The program accepts any number of ticket bookings.Press any number>3 as input to seat type for quitting the program. InputGet the following details:Seat type (Integer)(1 or 2 or 3)Name (String)With/without Refreshments (String)(WR or W)Press number>3 to exitOutputPrint the following details:Count of total bookings (Integer)(Eg:Count: 2)(Print only once at the beginning before printing other outputs)Seat typeNameWith/without RefreshmentsCalculated fee for that particular booking (Integer)(Eg:Fees: 2400)..............(for any no.of booking)Total cash collected for all bookings (Integer)(Eg:Total Cash: 4200)(Print finally once only after printing all other outputs)

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution 1

The task requires creating a Java program for an online movie ticket booking system. Here's a simple implementation of the task:

import java.util.Scanner;

class Ticket {
    String name;
    int seatType;
    String refreshment;
    static int totalBookings = 0;
    static int totalCash = 0;

    Ticket(int seatType, String name, String refreshment) {
        this.seatType = seatType;
        this.name = name;
        this.refreshment = refreshment;
        totalBookings++;
    }
}

class Calculation extends Ticket {
    Calculation(int seatType, String name, String refreshment) {
        super(seatType, name, refreshment);
    }

    int calculateFee() {
        int fee = 0;
        switch (seatType) {
            case 1:
                fee = refreshment.equals("WR") ? 1500 : 2000;
                break;
            case 2:
                fee = refreshment.equals("WR") ? 1600 : 2400;
                break;
            case 3:
                fee = refreshment.equals("WR") ? 1800 : 2800;
                break;
        }
        totalCash += fee;
        return fee;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println("Enter seat type (1, 2, 3, or >3 to exit): ");
            int seatType = scanner.nextInt();
            if (seatType > 3) break;
            System.out.println("Enter name: ");
            String name = scanner.next();
            System.out.println("With/without Refreshments (WR or W): ");
            String refreshment = scanner.next();
            Calculation booking = new Calculation(seatType, name, refreshment);
            System.out.println("Count: " + Ticket.totalBookings);
            System.out.println("Seat type: " + seatType);
            System.out.println("Name: " + name);
            System.out.println("With/without Refreshments: " + refreshment);
            System.out.println("Fees: " + booking.calculateFee());
        }
        System.out.println("Total Cash: " + Ticket.totalCash);
    }
}

This program creates a base class Ticket and a child class Calculation. The Ticket class keeps track of the total bookings and total cash collected. The Calculation class overrides the calculateFee method to calculate the fee based on the seat type and refreshment option. The main method prompts the user for input and creates a new Calculation object for each booking. It prints the booking details and the calculated fee. The program continues to accept bookings until the user enters a seat type greater than 3. Finally, it prints the total cash collected.

This problem has been solved

Solution 2

The problem statement is asking to create a Java program for an online movie ticket booking system. Here is a step-by-step guide on how to implement this:

  1. Create a base class Ticket:
public class Ticket {
    protected String name;
    protected int seatType;
    protected String refreshment;
    protected int fee;

    public Ticket(String name, int seatType, String refreshment) {
        this.name = name;
        this.seatType = seatType;
        this.refreshment = refreshment;
    }
}
  1. Create a child class Calculation that extends Ticket and overrides the method to calculate the fee:
public class Calculation extends Ticket {
    public Calculation(String name, int seatType, String refreshment) {
        super(name, seatType, refreshment);
        calculateFee();
    }

    private void calculateFee() {
        switch (seatType) {
            case 1:
                fee = refreshment.equals("WR") ? 1500 : 2000;
                break;
            case 2:
                fee = refreshment.equals("WR") ? 1600 : 2400;
                break;
            case 3:
                fee = refreshment.equals("WR") ? 1800 : 2800;
                break;
            default:
                System.out.println("Invalid seat type");
                System.exit(0);
        }
    }

    public int getFee() {
        return fee;
    }
}
  1. In the main method, create a loop to accept any number of ticket bookings. Use a list to store all the Calculation objects. Use a variable to keep track of the total cash collected and the count of total bookings:
public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    List<Calculation> bookings = new

This problem has been solved

Solution 3

Here is a simple Java program that implements the ticket booking process as described:

import java.util.Scanner;

class Ticket {
    String name;
    int seatType;
    String refreshment;
    static int totalBookings = 0;
    static int totalCash = 0;

    Ticket(String name, int seatType, String refreshment) {
        this.name = name;
        this.seatType = seatType;
        this.refreshment = refreshment;
        totalBookings++;
    }
}

class Calculation extends Ticket {
    Calculation(String name, int seatType, String refreshment) {
        super(name, seatType, refreshment);
        int fee = calculateFee();
        totalCash += fee;
        System.out.println("Seat type: " + seatType);
        System.out.println("Name: " + name);
        System.out.println("With/without Refreshments: " + refreshment);
        System.out.println("Fees: " + fee);
    }

    int calculateFee() {
        int fee = 0;
        switch (seatType) {
            case 1:
                fee = refreshment.equals("WR") ? 1500 : 2000;
                break;
            case 2:
                fee = refreshment.equals("WR") ? 1600 : 2400;
                break;
            case 3:
                fee = refreshment.equals("WR") ? 1800 : 2800;
                break;
        }
        return fee;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println("Enter seat type (1, 2, 3, or >3 to exit): ");
            int seatType = scanner.nextInt();
            if (seatType > 3) break;
            System.out.println("Enter name: ");
            String name = scanner.next();
            System.out.println("Enter refreshment type (WR or W): ");
            String refreshment = scanner.next();
            new Calculation(name, seatType, refreshment);
        }
        System.out.println("Count: " + Ticket.totalBookings);
        System.out.println("Total Cash: " + Ticket.totalCash);
    }
}

This program creates a base class Ticket and a child class Calculation. The Ticket class has a constructor that initializes the name, seat type, and refreshment type of a ticket. The Calculation class extends Ticket and overrides the calculateFee method to calculate the fee based on the seat type and refreshment type. The main method in the Main class prompts the user for input and creates a new Calculation object for each ticket. The program continues to prompt for input until the user enters a seat type greater than 3, at which point it prints the total number of bookings and the total cash collected.

This problem has been solved

Similar Questions

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

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: $30

A certain reservationist receives a call and makes a reservation for one room night for a future hotel guest. The traveler uses a credit card to guarantee the reservation, but no amount is charged to the traveler’s account. From an accounting standpoint, a sale ___________ and the event ____________. Group of answer choiceshas not been made; should not be recordedhas been made; should not be recordedhas not been made; should be recordedhas been made; should be recorded

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

1/2

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.