Assignment Chef icon Assignment Chef
All English tutorials

Programming lesson

Building a Movie Theater Manager in Java: A Step-by-Step Tutorial for CSE1322 Assignment 1

Learn to build a Java console application for a small theater that sells tickets and confections. This tutorial covers variables, loops, conditionals, and menu-driven programs with real-world examples.

Java movie theater manager CSE1322 assignment 1 Java console application menu-driven Java program Java variables and data types Java switch statement Java ticket selling program Java confection sales Java balance tracking Java tutorial for beginners Java assignment help Java programming 2025 Java theater POS system Java loop and conditional Java Scanner input Java assignment solution

Introduction: Managing a Virtual Movie Theater with Java

Imagine you're running a small movie theater in the summer of 2026. Blockbuster films like Avatar 5 and indie hits are drawing crowds, and you need a system to sell tickets, popcorn, soda, and candy while tracking your balance. In this tutorial, we'll build a Java program that does exactly that—a console-based movie theater manager inspired by the CSE1322 Assignment 1 (Fall 2025). You'll learn how to use variables, loops, conditionals, and a menu-driven interface to create a functional point-of-sale system.

Understanding the Problem: What Your Program Must Do

The assignment requires you to track the theater's seat availability, ticket price, confection prices (popcorn, soda, candy), and current balance. Your program must present a menu with eight options: sell tickets, end a movie session (reset seats), change ticket price, sell a confection, change a confection price, view balance, view prices, and quit. This is a classic example of a menu-driven Java program that uses a loop to repeatedly display options until the user chooses to exit.

Key Java Concepts You'll Practice

  • Variables and Data Types: Use int for whole numbers (seats, menu choice) and double for prices and balance. For example, int availableSeats = 50; and double ticketPrice = 30.0;.
  • Scanner for Input: Use Scanner to read user choices and amounts.
  • Switch or If-Else for Menu: Implement a loop that displays the menu and processes user input using a switch statement.
  • Validation: When selling tickets, check if enough seats are available before updating balance and seats.

Think of this like the ticket system for a hot concert—like a 2026 Taylor Swift Eras Tour stop. If only 50 seats remain, you can't sell 60 tickets. Your program must enforce that logic.

Step-by-Step Implementation Guide

1. Setting Up the Main Method and Variables

Start by declaring all variables in the main method. Use int for the number of seats and menu options, double for all monetary values. Initialize them as specified: 50 seats, $30 ticket, $25 popcorn, $10 soda, $15 candy, $0 balance.

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;

2. Creating the Menu Loop

Use a do-while loop to keep the program running until the user selects option 8. Inside the loop, print the menu and read the user's choice using a Scanner. Then use a switch statement to handle each option.

Scanner scanner = new Scanner(System.in);
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
            break;
        case 2: // end session
            break;
        // ... other cases
    }
} while (option != 8);

3. Implementing Each Menu Option

Sell Tickets (Option 1)

Prompt the user for the number of tickets to sell. If the requested amount is less than or equal to available seats, update seats and balance. Otherwise, print an error message. For example, if 30 tickets are sold at $30 each, balance increases by $900, and seats drop to 20.

System.out.print("Sell how many tickets? ");
int ticketsToSell = scanner.nextInt();
if (ticketsToSell <= availableSeats) {
    availableSeats -= ticketsToSell;
    balance += ticketsToSell * ticketPrice;
    System.out.printf("Sold %d tickets at $%.2f for a total of $%.2f%n", ticketsToSell, ticketPrice, ticketsToSell * ticketPrice);
} else {
    System.out.printf("Unable to sell %d tickets: Only %d seats available.%n", ticketsToSell, availableSeats);
}

End Movie Session (Option 2)

Simply reset available seats to 50. Print a message like "All seats have been vacated and cleaned."

availableSeats = 50;
System.out.println("All seats have been vacated and cleaned.");

Change Ticket Price (Option 3)

Prompt for the new price (a double) and update the variable.

System.out.print("Enter new ticket price: $");
double newPrice = scanner.nextDouble();
ticketPrice = newPrice;
System.out.println("Ticket price updated.");

Sell Confection (Option 4)

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

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;
}

Change Price of Confection (Option 5)

Ask which confection to update, then prompt for the new price. Update the appropriate variable.

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();
switch (confChoice) {
    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;
}

View Balance (Option 6)

Print the current balance with two decimal places.

System.out.printf("Current balance is $%.2f%n", balance);

View Prices (Option 7)

Display all current prices.

System.out.printf("Current prices: Ticket: $%.2f Popcorn: $%.2f Soda: $%.2f Candy: $%.2f%n", ticketPrice, popcornPrice, sodaPrice, candyPrice);

Quit (Option 8)

Print a goodbye message. The loop condition will exit.

System.out.println("Shutting off…");

Testing Your Program: Walk Through the Sample Output

Test each option as shown in the assignment. For example, start by viewing balance (should be $0.00). Then sell 30 tickets (balance becomes $900, seats 20). Try selling 25 tickets—should fail with "Only 20 seats available." Change ticket price to $45.50, then sell 15 tickets ($682.50 added). End session (seats reset to 50). Sell 42 tickets at $45.50 (balance $1911). View prices to confirm. Sell popcorn ($25), change candy price to $17.25, sell candy ($17.25). View balance should be $3535.75. Finally, quit.

Common Pitfalls and Tips

  • Data Types: Use double for prices and balance to handle decimal values like $45.50. Use int for seats and menu options.
  • Input Mismatch: If the user enters a non-integer for a menu choice, the program crashes. For this assignment, you can assume valid input, but consider using nextLine() and parsing in real-world apps.
  • Formatting Output: Use System.out.printf with %.2f to display currency with two decimal places.
  • Balance Update Rules: When selling tickets, only update balance if the sale succeeds. When selling confections, always add the price to balance.

Connecting to Real-World Trends (2026)

In 2026, many small businesses use similar POS systems. Think of this program as a simplified version of a theater's ticket kiosk, like those used at AMC or Regal. The concept of updating prices dynamically is also used in ride-sharing apps like Uber, where surge pricing changes based on demand. By mastering this assignment, you're building skills applicable to real-world Java programming for business applications.

Conclusion

You've now built a complete movie theater manager in Java. This project reinforces fundamental programming concepts: variables, loops, conditionals, and user input handling. The CSE1322 assignment is a perfect starting point for understanding how software manages inventory and transactions. As you progress, you could extend this program with features like multiple screens, loyalty discounts, or a graphical interface. Happy coding!