Programming lesson
Building a Movie Theater Manager in Java: A Step-by-Step Console App Tutorial
Learn how to build a simple Java console application that manages movie ticket sales, confection prices, and theater balance. This tutorial walks you through variables, loops, and a menu-driven program with real-world examples.
Introduction to the Movie Theater Manager Project
In this tutorial, you will learn how to create a Java console application that simulates a small theater's ticketing and concession stand. This project is perfect for beginners who want to practice variables, loops, conditionals, and user input. By the end, you'll have a functional theater management system that can sell tickets, update prices, and track balance.
Think of it like managing a real movie theater in 2026: with blockbuster releases like Avatar 5 or Super Mario Bros. 2, you need to handle ticket sales, popcorn, soda, and candy. This program does exactly that, but in a simplified console form.
Understanding the Requirements
The assignment asks you to track:
- Available seats (starting at 50)
- Ticket price (starting at $30)
- Popcorn price ($25), Soda price ($10), Candy price ($15)
- Theater balance (starting at $0)
Your program must present a menu with options: sell tickets, end movie session, change ticket price, sell confection, change confection price, view balance, view prices, and quit. Each option updates the appropriate variables.
Choosing the Right Data Types
For this program, use int for whole numbers (seats) and double for prices and balance. For example:
int availableSeats = 50;
double ticketPrice = 30.0;
double popcornPrice = 25.0;
double sodaPrice = 10.0;
double candyPrice = 15.0;
double balance = 0.0;Using double for money is fine for this assignment, though in real-world applications you'd use BigDecimal for precision.
Building the Menu Loop
The core of the program is a while loop that displays the menu and processes user choices. Use Scanner for input. Example structure:
Scanner scanner = new Scanner(System.in);
int option;
do {
System.out.println("[Movie Theater Manager]");
System.out.println("1. Sell tickets");
System.out.println("2. End movie session");
System.out.println("3. Change ticket price");
System.out.println("4. Sell confection");
System.out.println("5. Change price of confection");
System.out.println("6. View Balance");
System.out.println("7. View prices");
System.out.println("8. Quit");
System.out.print("Enter option: ");
option = scanner.nextInt();
switch (option) {
case 1: // sell tickets
case 2: // end session
// ... other cases
}
} while (option != 8);This loop continues until the user chooses to quit. Each case handles the corresponding feature.
Implementing Sell Tickets
When the user selects option 1, prompt for the number of tickets. Check if enough seats are available. If yes, update seats and balance. If not, print an error. Example:
System.out.print("Sell how many tickets? ");
int tickets = scanner.nextInt();
if (tickets <= availableSeats) {
availableSeats -= tickets;
balance += tickets * ticketPrice;
System.out.printf("Sold %d tickets at $%.2f for a total of $%.2f%n", tickets, ticketPrice, tickets * ticketPrice);
} else {
System.out.printf("Unable to sell %d tickets: Only %d seats available.%n", tickets, availableSeats);
}This logic ensures the balance only updates when the sale is successful.
End Movie Session
Option 2 resets available seats to 50. It does not affect balance or prices. Simple implementation:
availableSeats = 50;
System.out.println("All seats have been vacated and cleaned.");This simulates the end of a show, clearing the theater for the next screening.
Changing Ticket Price
Option 3 prompts for a new ticket price. Update the variable:
System.out.print("Enter new ticket price: $");
double newPrice = scanner.nextDouble();
ticketPrice = newPrice;
System.out.println("Ticket price updated.");Notice the sample output uses a dollar sign in the prompt. You can include it for clarity.
Selling Confections
Option 4 shows a submenu for popcorn, soda, or candy. Use a nested menu or integer choice. For example:
System.out.println("Sell what confection?");
System.out.println("1. Popcorn");
System.out.println("2. Soda");
System.out.println("3. Candy");
int confChoice = scanner.nextInt();
switch (confChoice) {
case 1:
balance += popcornPrice;
System.out.printf("Sold POPCORN for $%.2f%n", popcornPrice);
break;
case 2:
balance += sodaPrice;
System.out.printf("Sold SODA for $%.2f%n", sodaPrice);
break;
case 3:
balance += candyPrice;
System.out.printf("Sold CANDY for $%.2f%n", candyPrice);
break;
}This adds the confection price to the balance. No stock tracking is needed.
Changing Confection Prices
Option 5 is similar to selling but updates the price. First, ask which confection, then the new price:
System.out.println("Change price of which confection?");
System.out.println("1. Popcorn");
System.out.println("2. Soda");
System.out.println("3. Candy");
int choice = scanner.nextInt();
System.out.print("Enter new price: $");
double newPrice = scanner.nextDouble();
switch (choice) {
case 1:
popcornPrice = newPrice;
System.out.println("POPCORN price updated.");
break;
case 2:
sodaPrice = newPrice;
System.out.println("SODA price updated.");
break;
case 3:
candyPrice = newPrice;
System.out.println("CANDY price updated.");
break;
}This allows dynamic pricing, just like real theaters adjust for demand.
Viewing Balance and Prices
Option 6 displays the current balance using System.out.printf:
System.out.printf("Current balance is $%.2f%n", balance);Option 7 shows all prices:
System.out.println("Current prices:");
System.out.printf("Ticket: $%.2f%n", ticketPrice);
System.out.printf("Popcorn: $%.2f%n", popcornPrice);
System.out.printf("Soda: $%.2f%n", sodaPrice);
System.out.printf("Candy: $%.2f%n", candyPrice);Formatting with two decimal places makes it look professional.
Quit Option
Option 8 prints a goodbye message and exits the loop. The program terminates naturally.
System.out.println("Shutting off…");
break; // or let loop condition handleSince the loop condition is option != 8, setting option to 8 will exit.
Putting It All Together
Combine all the pieces inside the do-while loop. Remember to handle invalid menu choices (e.g., default in switch). The complete program should be around 100-150 lines. Test it with the sample output provided.
Real-World Application and Trends
This project mirrors real theater management software used by cinemas worldwide. In 2026, with the rise of dynamic pricing (like Uber surge pricing), your program can be extended to adjust prices based on demand. For example, you could add a feature that increases ticket price when few seats remain – similar to how concert tickets become more expensive as the event nears.
You can also connect this to gaming: think of it as an inventory system in a game like Stardew Valley or a shop in an RPG. The menu-driven interface is common in many applications, from ATMs to vending machines.
Conclusion
By completing this tutorial, you've built a functional Java console application that manages a small theater. You practiced variables, loops, conditionals, and user input – foundational skills for any programmer. Try extending it: add a loyalty program, track confection inventory, or save data to a file. Happy coding!