Assignment Chef icon Assignment Chef
All English tutorials

Programming lesson

Build a Movie Theater Manager in Java: A Step-by-Step Console App Tutorial

Learn to build a console-based movie theater management system in Java, covering variables, loops, conditionals, and menu-driven programs. Perfect for CSE1322 Assignment 1 practice.

Java tutorial movie theater manager console application Java CSE1322 assignment 1 Java menu-driven program Java variables and loops Java if-else Java switch case Java Scanner input Java double vs int Java ticket selling system Java balance tracking Java programming for beginners Java assignment help Java theater simulation Java point of sale

Introduction: Why Build a Theater Manager?

Imagine you're running a small movie theater in 2026. With summer blockbusters like Avatar 5 and Fast & Furious 11 drawing crowds, you need a simple but effective system to sell tickets, manage confections, and track your balance. In this tutorial, you'll build exactly that—a console-based Java application that handles ticket sales, seat availability, and snack pricing. This project mirrors the classic CSE1322 assignment 1 (Fall 2025) and is a fantastic way to practice variables, loops, conditionals, and menu-driven programs.

What You'll Learn

  • Using primitive data types (int, double) for real-world values
  • Implementing a loop-driven menu with Scanner for user input
  • Applying conditional logic for seat validation and price updates
  • Structuring a simple Java application with a single main method

Setting Up the Variables

Your program needs to track several pieces of data. Think of each as a storage box:

  • Available seats – starts at 50 (int)
  • Ticket price – starts at $30.00 (double)
  • Popcorn price – $25.00 (double)
  • Soda price – $10.00 (double)
  • Candy price – $15.00 (double)
  • Theater balance – starts at $0.00 (double)

In Java, you declare them like this:

int availableSeats = 50;
double ticketPrice = 30.00;
double popcornPrice = 25.00;
double sodaPrice = 10.00;
double candyPrice = 15.00;
double balance = 0.00;

Notice we use int for whole numbers (seats) and double for monetary values. This follows the assignment's hint: prefer int for whole numbers, double for decimals.

Building the Menu Loop

The heart of the program is a loop that repeatedly shows options until the user chooses to quit. A do-while loop works perfectly because the menu must display at least once.

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();
    // handle option using switch or if-else
} while (option != 8);

Implementing Each Feature

1. Sell Tickets

When the user selects option 1, prompt for the number of tickets to sell. Check if enough seats are available. If yes, update seats and balance. If not, print an error and do not modify anything.

if (option == 1) {
    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);
    }
}

2. End Movie Session

Resets available seats to 50. This simulates the end of a show, clearing the theater for the next screening.

if (option == 2) {
    availableSeats = 50;
    System.out.println("All seats have been vacated and cleaned.");
}

3. Change Ticket Price

Ask the user for a new ticket price and update the variable.

if (option == 3) {
    System.out.print("Enter new ticket price: $");
    ticketPrice = scanner.nextDouble();
    System.out.println("Ticket price updated.");
}

4. Sell Confection

Display a submenu for popcorn, soda, or candy. Based on the choice, add the corresponding price to the balance.

if (option == 4) {
    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();
    if (confChoice == 1) {
        balance += popcornPrice;
        System.out.printf("Sold POPCORN for $%.2f%n", popcornPrice);
    } else if (confChoice == 2) {
        balance += sodaPrice;
        System.out.printf("Sold SODA for $%.2f%n", sodaPrice);
    } else if (confChoice == 3) {
        balance += candyPrice;
        System.out.printf("Sold CANDY for $%.2f%n", candyPrice);
    }
}

5. Change Price of Confection

Similar to selling, but instead of adding to balance, you update the price. Ask which confection, then prompt for the new price.

if (option == 5) {
    System.out.println("Change price of which confection?");
    System.out.println("1. Popcorn");
    System.out.println("2. Soda");
    System.out.println("3. Candy");
    int confChoice = scanner.nextInt();
    System.out.print("Enter new price: $");
    double newPrice = scanner.nextDouble();
    if (confChoice == 1) {
        popcornPrice = newPrice;
        System.out.println("POPCORN price updated.");
    } else if (confChoice == 2) {
        sodaPrice = newPrice;
        System.out.println("SODA price updated.");
    } else if (confChoice == 3) {
        candyPrice = newPrice;
        System.out.println("CANDY price updated.");
    }
}

6 & 7. View Balance and Prices

Simply print the current values.

if (option == 6) {
    System.out.printf("Current balance is $%.2f%n", balance);
}
if (option == 7) {
    System.out.printf("Current prices:%nTicket: $%.2f%nPopcorn: $%.2f%nSoda: $%.2f%nCandy: $%.2f%n", ticketPrice, popcornPrice, sodaPrice, candyPrice);
}

8. Quit

The loop condition option != 8 will exit when the user selects 8. You can add a farewell message before the loop ends.

if (option == 8) {
    System.out.println("Shutting off...");
}

Putting It All Together

Combine all the pieces inside the do-while loop. Use a switch or if-else if chain to handle each option. Remember to close the Scanner after the loop to avoid resource leaks.

Here's the skeleton of the complete main method:

import java.util.Scanner;

public class MovieTheater {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int availableSeats = 50;
        double ticketPrice = 30.00;
        double popcornPrice = 25.00;
        double sodaPrice = 10.00;
        double candyPrice = 15.00;
        double balance = 0.00;
        int option;
        do {
            // display menu
            // read option
            // handle option
        } while (option != 8);
        scanner.close();
    }
}

Testing Your Program

Run your program and try the sample interactions from the assignment. For example:

  • Select option 6 to view balance (should be $0.00)
  • Sell 30 tickets (balance becomes $900.00, seats become 20)
  • Try selling 25 tickets (should fail with error: only 20 seats)
  • Change ticket price to $45.50
  • Sell 15 tickets (balance adds $682.50)
  • End movie session (seats reset to 50)
  • Sell 42 tickets (balance adds $1911.00)
  • View prices, sell confections, change candy price, etc.

Your final balance should match the sample output: $3535.75 after all those steps.

Common Pitfalls and Tips

  • Data types: Use double for money to handle decimal values. int for seat counts.
  • Input validation: The assignment doesn't require checking for negative numbers or non-numeric input, but you can add that for extra credit.
  • Formatting: Use System.out.printf with %.2f to display two decimal places for currency.
  • Menu loop: Ensure the loop only exits on option 8. Don't forget to consume the newline after nextInt() if you later use nextLine().

Connecting to the Real World

This project simulates a real point-of-sale system. In 2026, theaters are using similar software to manage dynamic pricing—ticket prices might change based on demand, just like surge pricing on Uber. Concession stands are a major profit center; a 2025 study showed that theaters earn 85% of their profit from snacks. By building this app, you're learning the fundamentals of inventory and transaction management used in everything from e-commerce to vending machines.

Next Steps

Once you have the basic version working, consider extending it:

  • Add a loyalty program that gives a free ticket after 10 purchases.
  • Implement discount days (e.g., Tuesday tickets are half price).
  • Store sales history in an array or file.

This assignment is your first step into building interactive Java applications. Master it, and you'll have a solid foundation for more complex projects like GUI apps or web backends.