Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Class MovieTicketBookingSystem: Define a class MovieTicketBookingSystem with a main method. Create a Scanner object to get input from the user. Create a NumberFormat object. Create

Class MovieTicketBookingSystem:

Define a class MovieTicketBookingSystem with a main method.

Create a Scanner object to get input from the user.

Create a NumberFormat object.

Create an ArrayList tickets of type Ticket to store the ticket information.

Use a while loop to prompt the user to enter the movie information, including the movie name, ticket count, and age of the moviegoer. Store each ticket in the tickets ArrayList.

Use another while loop to iterate through the tickets ArrayList and output the information for each transaction, including the movie name, ticket count, age, ticket price, and total cost. Use the NumberFormat object to format currency values in the output.

Calculate the total cost of all tickets and output it.

Close the Scanner object when done.

(BELOW IS THE CODE GIVEN, WE NEED TO USE THAT CODE AND FIX IT TO MAKE SURE THE OUTPUT LOOKS LIKE THIS:)

---------------------------------------------------------------------------------

WHAT THE OUTPUT NEEDS TO LOOK LIKE:

Enter the movie name (or 'q' to quit): Movie1 Enter the number of tickets: 2 Enter the age of the moviegoer: 25 Enter the movie name (or 'q' to quit): Movie2 Enter the number of tickets: 3 Enter the age of the moviegoer: 16 Enter the movie name (or 'q' to quit): q =============================== Transaction #1 Movie Name: Movie1 Ticket Count: 2 Age: 25 Ticket Price: $15.00 Total Cost: $$30.00 Transaction #2 Movie Name: Movie2 Ticket Count: 3 Age: 16 Ticket Price: $12.00 Total Cost: $$36.00 Total Cost of All Tickets: $66.00

---------------------------------------------------------------------------------

(THIS IT THE CODE GIVEN THAT WE NEED TO FIX) please help!

Class MovieTicketBookingSystem:

import java.util.ArrayList; import java.util.Scanner; import java.text.NumberFormat; public class MovieTicketBookingSystem { public static void main(String[] args) { Scanner sc = new Scanner(System.in); ArrayList tickets = new ArrayList<>(); NumberFormat currencyFormat = // TODO // Prompt the user to enter movie information while (true) { System.out.print("Enter the movie name (or 'q' to quit): "); String movieName = sc.nextLine(); // If user has entered 'q' for movieName, break out of the while loop if (// TODO) { break; } System.out.print("Enter the number of tickets: "); int ticketCount = Integer.parseInt(sc.nextLine()); System.out.print("Enter the age of the moviegoer: "); int age = Integer.parseInt(sc.nextLine()); // Create a Ticket object using its constructor Ticket ticket = // TODO // Add the object to the tickets ArrayList // TODO } System.out.println("=============================== "); // Calculate the total cost of all tickets double totalCost = 0.0; int i = 1; // Iterate through the tickets ArrayList and display the information for each transaction while (i <= tickets.size()) { Ticket ticket = tickets.get(i - 1); System.out.println("Transaction #" + i); System.out.println("Movie Name: " + ticket.getMovieName()); System.out.println("Ticket Count: " + // TODO); System.out.println("Age: " + // TODO); System.out.println("Ticket Price: " + currencyFormat.format(ticket.getTicketPrice())); System.out.println("Total Cost: " + // TODO); System.out.println(); totalCost += // TODO i++; } // Display the total cost of all tickets System.out.println("Total Cost of All Tickets: " + // TODO); } } 

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

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

Was there an effort to involve the appropriate people?

Answered: 1 week ago

Question

18. If you have power, then people will dislike and fear you.

Answered: 1 week ago