Purpose of Program Using a loop structure.
Chapter 4 Textbook
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.
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