A. Purpose of the Program

Purpose of Program Using a loop structure.

B. Required Reading

Chapter 4 Textbook

C. Exercise

Exercise 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, Adult, Child
1, 9.50, 6.00
2, 12.50, 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.

E. Example Input and Output

Example input and output Note: red indicates the user input from the keyboard

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
Theater 1:
Adult Tickets: 18
Child Tickets: 9
Amount (total): $225.00
Theater 2:
Adult Tickets: 21
Child Tickets: 14
Amount (total): $367.50
Total Amount: $592.50
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.