This class is part of a larger application that will take a number of variables from the user, and expect to use them later, even after this particular class is left.
How can I grab the data that this class takes (after multiple iterations), and call it back from a different section?
public class A8AirlineAircraftData {
public static void AddAirline(){
Scanner sc = new Scanner(System.in);
System.out.println("Please enter the Airline name: ");
String airName = sc.nextLine();
System.out.println("Please enter the Airline code: ");
String airCode = sc.nextLine();
System.out.println("Please enter the Delta Aircraft: ");
String airCraft = sc.nextLine();
System.out.println("Please enter the first class seat capacity: ");
int firstClass = sc.nextInt();
System.out.println("Please enter the business class seat capacity: ");
int busiClass = sc.nextInt();
System.out.println("Please enter the economy class seat capacity: ");
int econClass = sc.nextInt();
System.out.println("Airline name: " + airName);
System.out.println("Airline code: " + airCode);
System.out.println("Delta Aircraft: " + airCraft);
String arr[] = airCraft.split(" ", 2);
String firstWord = arr[0];
System.out.println(firstWord + " first class seat capacity: " + firstClass);
System.out.println(firstWord + " business class seat capacity: " + busiClass);
System.out.println(firstWord + " economy class seat capacity: " + econClass);
System.out.println( airName + " successfully added. Press Enter to continue.");
sc.nextLine();//Press Enter to continue
sc.nextLine();
A8MainMenu.mainMenu(); //return to main menu after Enter.
} //AddAirline
My output now:
Airline name: Qatar Airlines
Airline code: QA
Delta Aircraft: Boeing 787 Dreamliner
Boeing first class seat capacity: 16
Boeing business class seat capacity: 25
Boeing economy class seat capacity: 199
Qatar Airlines successfully added. Press Enter to continue.
I need to just store this information somewhere in memory until I can call it later.