Building a Console-Based Maintenance Helpdesk System in Java

Published: (January 15, 2026 at 07:44 AM EST)
6 min read
Source: Dev.to

Source: Dev.to

Describing the Features

Below are three key features of the program. For each, I provide a detailed description of the code, linking the practical implementation to the theoretical concepts covered in the course.

Maintenance Request Tracker

1 - Add a request
2 - View a request
3 - Administrator
4 - Exit
Please choose an option 1‑4:

User Input

User input is the core of the help‑desk program; all interactions occur through the console. Java’s Scanner class reads input, enabling navigation of menu options, creation of maintenance requests, and entry of reference numbers when updating or closing jobs.

int choice = 0;               // Stores the menu option chosen by the user.
boolean validChoice = false; // Ensures only valid input is accepted.

while (!validChoice) {        // Loop until the user enters a valid number.
    try {
        System.out.println("Please choose an option 1‑4:");
        choice = input.nextInt(); // Reads the menu choice as a number.
        input.nextLine();        // Clears the scanner buffer.
        validChoice = true;      // Exit loop if a valid choice was entered.
    } catch (Exception e) {
        System.out.println("Invalid input, please choose a number between 1 and 4");
        input.nextLine();        // Discard the invalid input.
    }
}

Key points

  • nextInt() reads only the numeric value and leaves the newline character in the buffer.
  • An extra nextLine() call clears that leftover newline before the next text input.
  • The try / catch block prevents the program from crashing when a non‑numeric character is entered.

Reference‑Number Validation

while (!validRef) {
    try {
        System.out.println("Please enter your request reference number:");
        refNumber = input.nextInt();
        input.nextLine();          // Clear buffer.
        validRef = true;
    } catch (Exception e) {
        System.out.println("Invalid input, please enter the correct number");
        input.nextLine();          // Discard the invalid input.
    }
}

This defensive‑programming approach ensures the application remains robust and user‑friendly, reducing runtime errors. It directly reflects the concepts covered in Bootcamp Lecture 3 on handling user input with Scanner.

Selection Statements

Selection statements control how the program responds to user input. In a menu‑driven console application, they determine which part of the program runs next.

if (choice == 1) {
    addRequest();
} else if (choice == 2) {
    viewRequest();
} else if (choice == 3) {
    adminMenu();
} else if (choice == 4) {
    System.out.println("Exiting Programme");
    running = false;
} else {
    System.out.println("Invalid Option Chosen");
}
  • If / else‑if statements make each possible path explicit, improving readability and maintainability as the program grows.
  • This demonstrates the core structured‑programming concepts of selection and control flow.

Building Selection Example

String buildingName = "";          // Will hold the building name once selected.
boolean validBuilding = false;    // Loop until a valid building is chosen.

while (!validBuilding) {
    try {
        System.out.println("Building Name (Choose 1‑5):");
        System.out.println("1 - Simon");
        System.out.println("2 - Beyer");
        System.out.println("3 - Michael Smith");
        System.out.println("4 - Stopford");
        System.out.println("5 - Alan Turing");

        int buildingChoice = input.nextInt(); // Stores the building option.
        input.nextLine();                     // Clear scanner buffer.

        // Map the numeric choice to a building name.
        switch (buildingChoice) {
            case 1 -> buildingName = "Simon";
            case 2 -> buildingName = "Beyer";
            case 3 -> buildingName = "Michael Smith";
            case 4 -> buildingName = "Stopford";
            case 5 -> buildingName = "Alan Turing";
            default -> {
                System.out.println("Invalid building number, please try again.");
                continue; // Prompt again.
            }
        }
        validBuilding = true;
    } catch (Exception e) {
        System.out.println("Invalid input, please enter a number between 1 and 5");
        input.nextLine(); // Discard the invalid input.
    }
}

Selection is also used throughout the program for:

  • Choosing a priority level
  • Confirming a Y/N action
  • Validating any other user‑driven choices

Conclusion

By combining input validation, exception handling, and selection statements, the maintenance help‑desk system demonstrates solid, defensive programming practices. These techniques not only align with the theoretical material covered in the apprenticeship bootcamp but also produce a reliable, user‑friendly console application.

Overview

The maintenance help‑desk system stores and manages data using Java’s ArrayList class. ArrayLists hold data on maintenance requests and technicians, allowing the program to store multiple objects and manage them dynamically.

private static ArrayList request = new ArrayList<>();
private static ArrayList technician = new ArrayList<>();

From a theoretical perspective, ArrayList is part of Java’s collections framework and represents a dynamic data structure—its size can grow or shrink at runtime. This makes it more suitable than a fixed‑size array when the amount of data is unknown in advance. In our program the user can continuously add new requests and technicians, so a dynamic structure is essential.

Request newRequest = new Request(
        refNumber, requester, telephone,
        buildingName, description, priority);
request.add(newRequest);

New objects are added to these lists as they are created. When a new maintenance request is added, the Request object is instantiated and stored in the request list.

private static int findRequest(int refNumber) {
    for (int i = 0; i = 1 && choice <= 4) {
        validChoice = true;
    } else {
        System.out.println("Invalid option, please choose between 1 and 4");
    }
}

Fix: Added additional validation checks to ensure only valid menu options are accepted. If an invalid option is entered, an error message prompts the user to re‑enter a correct choice. This improvement prevented invalid selections and reinforced the importance of input validation in interactive programs.

Issue 3 – Duplicate Reference Numbers

Each request and technician must have a unique reference number for later retrieval.

// Auto‑generate reference numbers
private static int nextRequestRef = 1001;
private static int nextTechNumber   = 1;

Cause: When pre‑populated test data were added at program start, the counters (nextRequestRef, nextTechNumber) were not updated, causing newly created objects to receive duplicate reference numbers.

Fix: Updated the counters after inserting test data so that subsequent objects receive the next available unique number.

int refNumber = nextRequestRef;
nextRequestRef++;

Request newRequest = new Request(
        refNumber, requester, telephone,
        buildingName, description, priority);
request.add(newRequest);

Managing this issue emphasized the need to keep program state consistent, especially when identifiers are generated automatically.

Conclusion

Developing the maintenance help‑desk system deepened my understanding of Java programming, particularly:

  • Handling mixed user input (numbers and text) safely.
  • Using selection statements and validating menu choices.
  • Managing dynamic data with ArrayLists.

As the program grew in size, I also realized the importance of state management (e.g., unique identifiers) and robust input validation to ensure reliable, maintainable software.

Reflection on Code Refactoring

Splitting the code into separate classes helped me partially tidy up my code, making it easier to read. However, I would have liked to further improve this, as I felt there were additional enhancements I could have made.

If I were to develop my code further, I would like to add read and write functionality so that the data could be saved and loaded between sessions rather than being reset once the program closed.

Overall, this project helped me understand the importance of good structure, input validation, and the need to plan and organize code carefully.

Back to Blog

Related posts

Read more »

Spring Data JPA Relationships

Introduction Happy New Year! In the past ten days of my full‑stack journey, I have been working on projects right after joining. Initially, I struggled with Re...

My TicketDesk System

Intro For my Intro to Programming module, I made a TicketDesk system in Java that can: - Track tickets - Track login information - Provide a role‑based authent...