light assignment runs but there is no imput values for the user to interact when running the program. Kindly fix this issue. import java.util.*; class Flight {     String airlineCode;     int flightNumber;     char type; // D for domestic, I for international     String departureAirportCode;     String departureGate;     char departureDay;     int departureTime;     String arrivalAirportCode;     String arrivalGate;     char arrivalDay;     int arrivalTime;     char status; // S for scheduled, A for arrived, D for departed     public Flight(String airlineCode, int flightNumber, char type, String departureAirportCode,                   String departureGate, char departureDay, int departureTime,                   String arrivalAirportCode, String arrivalGate, char arrivalDay, int arrivalTime) {         this.airlineCode = airlineCode;         this.flightNumber = flightNumber;         this.type = type;         this.departureAirportCode = departureAirportCode;         this.departureGate = departureGate;         this.departureDay = departureDay;         this.departureTime = departureTime;         this.arrivalAirportCode = arrivalAirportCode;         this.arrivalGate = arrivalGate;         this.arrivalDay = arrivalDay;         this.arrivalTime = arrivalTime;         this.status = 'S'; // Default status is scheduled     } } class Airline {     String name;     String code;     int firstClassCapacity;     int businessClassCapacity;     int economyClassCapacity;     public Airline(String name, String code, int firstClassCapacity, int businessClassCapacity, int economyClassCapacity) {         this.name = name;         this.code = code;         this.firstClassCapacity = firstClassCapacity;         this.businessClassCapacity = businessClassCapacity;         this.economyClassCapacity = economyClassCapacity;     } } class FlightScheduler {     static Scanner scanner = new Scanner(System.in);     static List flights = new ArrayList<>();     static List airlines = new ArrayList<>();     static char currentDay;     static int currentTime;     public static void main(String[] args) {         displayWelcomeScreen();         handleMenu();     }     private static void displayWelcomeScreen() {         System.out.println("Welcome to the Flight Scheduler!");         System.out.println("Please remember to always use U, M, T, W, R, F, S for entering the day of the week,");         System.out.println("and to always use military time for entering the time.");         System.out.println("\nPlease make your choice by entering the corresponding menu number:");     }     private static void handleMenu() {         while (true) {             System.out.println("\n1. Set Clock  2. Clear Schedule  3. Add Airline  4. Add Flight");             System.out.println("5. Cancel Flight  6. Show Flight Info  7. Show Departures  8. Show Arrivals  9. Find Flights Between Two Airports  10. Exit");             System.out.print("\nEnter your choice: ");             int choice = scanner.nextInt();             scanner.nextLine(); // Consume the newline character             switch (choice) {                 case 1:                     setClock();                     break;                 case 2:                     clearSchedule();                     break;                 case 3:                     addAirline();                     break;                 case 4:                     addFlight();                     break;                 case 10:                     System.out.println("Exiting program. Goodbye!");                     System.exit(0);                     break;                 default:                     System.out.println("Invalid choice. Please try again.");             }         }     }     private static void setClock() {         System.out.print("Enter U, M, T, W, R, F, or S for the corresponding day of the week: ");         currentDay = scanner.next().charAt(0);

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter7: Using Methods
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question

Flight assignment runs but there is no imput values for the user to interact when running the program. Kindly fix this issue.

import java.util.*;

class Flight {
    String airlineCode;
    int flightNumber;
    char type; // D for domestic, I for international
    String departureAirportCode;
    String departureGate;
    char departureDay;
    int departureTime;
    String arrivalAirportCode;
    String arrivalGate;
    char arrivalDay;
    int arrivalTime;
    char status; // S for scheduled, A for arrived, D for departed

    public Flight(String airlineCode, int flightNumber, char type, String departureAirportCode,
                  String departureGate, char departureDay, int departureTime,
                  String arrivalAirportCode, String arrivalGate, char arrivalDay, int arrivalTime) {
        this.airlineCode = airlineCode;
        this.flightNumber = flightNumber;
        this.type = type;
        this.departureAirportCode = departureAirportCode;
        this.departureGate = departureGate;
        this.departureDay = departureDay;
        this.departureTime = departureTime;
        this.arrivalAirportCode = arrivalAirportCode;
        this.arrivalGate = arrivalGate;
        this.arrivalDay = arrivalDay;
        this.arrivalTime = arrivalTime;
        this.status = 'S'; // Default status is scheduled
    }
}

class Airline {
    String name;
    String code;
    int firstClassCapacity;
    int businessClassCapacity;
    int economyClassCapacity;

    public Airline(String name, String code, int firstClassCapacity, int businessClassCapacity, int economyClassCapacity) {
        this.name = name;
        this.code = code;
        this.firstClassCapacity = firstClassCapacity;
        this.businessClassCapacity = businessClassCapacity;
        this.economyClassCapacity = economyClassCapacity;
    }
}

class FlightScheduler {
    static Scanner scanner = new Scanner(System.in);
    static List<Flight> flights = new ArrayList<>();
    static List<Airline> airlines = new ArrayList<>();
    static char currentDay;
    static int currentTime;

    public static void main(String[] args) {
        displayWelcomeScreen();
        handleMenu();
    }

    private static void displayWelcomeScreen() {
        System.out.println("Welcome to the Flight Scheduler!");
        System.out.println("Please remember to always use U, M, T, W, R, F, S for entering the day of the week,");
        System.out.println("and to always use military time for entering the time.");
        System.out.println("\nPlease make your choice by entering the corresponding menu number:");
    }

    private static void handleMenu() {
        while (true) {
            System.out.println("\n1. Set Clock  2. Clear Schedule  3. Add Airline  4. Add Flight");
            System.out.println("5. Cancel Flight  6. Show Flight Info  7. Show Departures  8. Show Arrivals  9. Find Flights Between Two Airports  10. Exit");
            System.out.print("\nEnter your choice: ");
            int choice = scanner.nextInt();
            scanner.nextLine(); // Consume the newline character
            switch (choice) {
                case 1:
                    setClock();
                    break;
                case 2:
                    clearSchedule();
                    break;
                case 3:
                    addAirline();
                    break;
                case 4:
                    addFlight();
                    break;
                case 10:
                    System.out.println("Exiting program. Goodbye!");
                    System.exit(0);
                    break;
                default:
                    System.out.println("Invalid choice. Please try again.");
            }
        }
    }

    private static void setClock() {
        System.out.print("Enter U, M, T, W, R, F, or S for the corresponding day of the week: ");
        currentDay = scanner.next().charAt(0);
        System.out.print("Please enter the time in military notation: ");
        currentTime = scanner.nextInt();
        System.out.println("Day set to " + currentDay + " and time set to " + currentTime);
        scanner.nextLine(); // Consume the newline character
        System.out.print("Press Enter to continue...");
        scanner.nextLine(); // Wait for Enter key
    }

private static void clearSchedule() {
        System.out.print("Are you sure you want to clear the schedule and start over? (y/n) ");
        char response = scanner.next().charAt(0);
        if (response == 'y' || response == 'Y') {
            flights.clear();
            System.out.println("Schedule cleared. Press Enter to continue...");
            scanner.nextLine(); // Consume the newline character
            scanner.nextLine(); // Wait for Enter key
        }
    }

 

}
private static void addAirline () {
}
System.out.print(s: "Airline name: ");
String name= scanner.nextLine ();
System.out.print (s: "Airline code: ");
String code = scanner.nextLine();
System.out.print(s: "First class seat capacity: ");
int firstClassCapacity = scanner.nextInt ();
System.out.print (s: "Business class seat capacity: ");
int businessClassCapacity = scanner.nextInt ();
System.out.print (s: "Economy class seat capacity: ");
int economyClassCapacity= scanner.nextInt ();
Airline airline = new Airline (name, code, firstClassCapacity, business ClassCapacity, economyClassCapacity
airlines.add (e: airline);
System.out.println (name + " successfully added. Press Enter to continue...");
scanner.nextLine(); // Consume the newline character
scanner.nextLine(); // Wait for Enter key
private static void addFlight () {
System.out.print (s: "Airline code: ");
String airlineCode = scanner.nextLine ();
Airline airline = findAirline (code: airlineCode);
if (airline == null) {
System.out.print (airline Code + " was not found. Try again? (y/n) ");
char response = scanner.next().charAt(index: 0);
if (response == 'y' || response == 'Y') {
addFlight ();
}
} else {
System.out.print (s: "Flight number: ");
int flightNumber = scanner.nextInt ();
System.out.print (s: "Type (D for domestic or I for international): ");
char type = scanner.next().charAt(index: 0);
Transcribed Image Text:} private static void addAirline () { } System.out.print(s: "Airline name: "); String name= scanner.nextLine (); System.out.print (s: "Airline code: "); String code = scanner.nextLine(); System.out.print(s: "First class seat capacity: "); int firstClassCapacity = scanner.nextInt (); System.out.print (s: "Business class seat capacity: "); int businessClassCapacity = scanner.nextInt (); System.out.print (s: "Economy class seat capacity: "); int economyClassCapacity= scanner.nextInt (); Airline airline = new Airline (name, code, firstClassCapacity, business ClassCapacity, economyClassCapacity airlines.add (e: airline); System.out.println (name + " successfully added. Press Enter to continue..."); scanner.nextLine(); // Consume the newline character scanner.nextLine(); // Wait for Enter key private static void addFlight () { System.out.print (s: "Airline code: "); String airlineCode = scanner.nextLine (); Airline airline = findAirline (code: airlineCode); if (airline == null) { System.out.print (airline Code + " was not found. Try again? (y/n) "); char response = scanner.next().charAt(index: 0); if (response == 'y' || response == 'Y') { addFlight (); } } else { System.out.print (s: "Flight number: "); int flightNumber = scanner.nextInt (); System.out.print (s: "Type (D for domestic or I for international): "); char type = scanner.next().charAt(index: 0);
}
} else {
}
System.out.print (s: "Flight number: ");
int flightNumber = scanner.nextInt ();
System.out.print(s: "Type (D for domestic or I for international): ");
char type = scanner.next () .charAt (index: 0);
System.out.print (s: "Departure airport code: ");
String departureAirportCode= scanner.next();
System.out.print (s: "Departure gate: ");
}
String departureGate = scanner.next ();
System.out.print (s: "Departure day: ");
char departureDay = scanner.next () .charAt (index: 0);
System.out.print (s: "Departure time: ");
int departureTime = scanner.nextInt ();
System.out.print (s: "Arrival airport code: ");
String arrivalAirportCode = scanner.next();
System.out.print (s: "Arrival gate: ");
String arrivalGate = scanner.next ();
System.out.print (s: "Arrival day: ");
char arrival Day = scanner.next () .charAt (index: 0);
System.out.print (s: "Arrival time: ");
int arrivalTime = scanner.nextInt ();
Flight flight = new Flight (airlineCode, flightNumber, type, departureAirportCode, departureGate,
departureDay, departureTime, arrivalAirportCode, arrivalGate, arrivalDay, arrivalTime);
flights.add (e: flight);
System.out.println("Flight " + airline Code + flightNumber + " scheduled successfully. Press Enter to continue...");
scanner.nextLine (); // Consume the newline character
scanner.nextLine (); // Wait for Enter key
private
static Airline findAirline (String code) {
for (Airline airline : airlines) {
if (airline.code.equals (anobject: code)) {
return airline;
}
return null;
Transcribed Image Text:} } else { } System.out.print (s: "Flight number: "); int flightNumber = scanner.nextInt (); System.out.print(s: "Type (D for domestic or I for international): "); char type = scanner.next () .charAt (index: 0); System.out.print (s: "Departure airport code: "); String departureAirportCode= scanner.next(); System.out.print (s: "Departure gate: "); } String departureGate = scanner.next (); System.out.print (s: "Departure day: "); char departureDay = scanner.next () .charAt (index: 0); System.out.print (s: "Departure time: "); int departureTime = scanner.nextInt (); System.out.print (s: "Arrival airport code: "); String arrivalAirportCode = scanner.next(); System.out.print (s: "Arrival gate: "); String arrivalGate = scanner.next (); System.out.print (s: "Arrival day: "); char arrival Day = scanner.next () .charAt (index: 0); System.out.print (s: "Arrival time: "); int arrivalTime = scanner.nextInt (); Flight flight = new Flight (airlineCode, flightNumber, type, departureAirportCode, departureGate, departureDay, departureTime, arrivalAirportCode, arrivalGate, arrivalDay, arrivalTime); flights.add (e: flight); System.out.println("Flight " + airline Code + flightNumber + " scheduled successfully. Press Enter to continue..."); scanner.nextLine (); // Consume the newline character scanner.nextLine (); // Wait for Enter key private static Airline findAirline (String code) { for (Airline airline : airlines) { if (airline.code.equals (anobject: code)) { return airline; } return null;
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,