Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A movie company has two theaters (Theater 1, Theater 2) to show movies at one ti

ID: 3772317 • Letter: A

Question

A movie company has two theaters (Theater 1, Theater 2) to show movies at one time. The cost of viewing a movie is as follows.

Theater 1
Adult 9.50
Child 6.00

Theater 2
Adult 12.50
Child 7.50


Write a Java program that prompts for each of the following in the order given.
1.Theater Number
2.Number of Adult Tickets
3.Number of Child Tickets
The program should then print the total amount needed for the tickets requested.
The program must run in a loop using the sentinel -999. When the loop terminates, display the number of tickets for each theater for both child and adult that are sold and display a total amount collected for that day. Display all dollar amounts to two decimal places. Make your output attractive and include appropriate comments in your program.
Sample input and output (red indicates the user input)
Enter theater number: 1 Adult Tickets: 10 Child Tickets: 5
Enter theater number: 2 Adult Tickets: 15 Child Tickets: 10
Enter theater number: 2 Adult Tickets: 6 Child Tickets: 4
Enter theater number: 1 Adult Tickets: 8 Child Tickets: 4
Enter theater number: -999
// Input complete, the following will display the receipt information:
Theater 1:
Adult Tickets: 18
Child Tickets: 9
Amount (total): $225.00
Theater 2:
Adult Tickets: 21
Child Tickets: 14
Amount (total): $283.5
Total Amount: $508.5

Explanation / Answer

public class Thtr
{
public static void main(String[] args)
{
Scanner kbd = new Scanner(System.in);
float theater1Total = 0f, theater2Total = 0f;
int theater1Tickets_adult = 0, theater2Tickets_adult = 0;
int theater1Tickets_child = 0, theater2Tickets_child = 0;
while(true)
{
System.out.println(" Please enter Theater Number: ");
int theaterNumber = kbd.nextInt();
if(theaterNumber == -999)break;
System.out.println("Number of Adult Tickets: ");
int adultTickets = kbd.nextInt();
System.out.println("Number of Child Tickets: ");
int childTickets = kbd.nextInt();
if(theaterNumber == 1)
{
theater1Tickets_adult += adultTickets;
theater1Tickets_child += childTickets;
theater1Total += (adultTickets * 9.50) + (childTickets * 6.00);
}
else if(theaterNumber == 2)
{
theater2Tickets_adult += adultTickets;
theater2Tickets_child += childTickets;
theater2Total += (adultTickets * 12.50) + (childTickets * 7.50);
}
}
System.out.println(" Theater 1: ");
System.out.println("Adult Tickets: "+theater1Tickets_adult+" ");
System.out.println("Child Tickets: "+theater1Tickets_child+" ");
System.out.println("Amount (total): "+theater1Total+" ");
System.out.println(" Theater 2: ");
System.out.println("Adult Tickets: "+theater2Tickets_adult+" ");
System.out.println("Child Tickets: "+theater2Tickets_child+" ");
System.out.println("Amount (total): "+theater2Total+" ");
System.out.println(" Total Amount: "+(theater1Total+theater2Total));
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote