// Driver public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("What file do you want to use for input/output?"); String filename = input.nextLine(); Airline a = new Airline(filename); String city1, city2; loop: while (true) { System.out.println("\n\tWhat would you like to do?"); System.out.println("\t1: See All Direct Routes"); System.out.println("\t2: Find Minimum Spanning Tree"); System.out.println("\t3: Find Shortest Path by Distance"); System.out.println("\t4: Find Shortest Path by Cost"); System.out.println("\t5: Find Shortest Path by Hops"); System.out.println("\t6: Find Trips Under Cost"); System.out.println("\t7: Add a Route"); System.out.println("\t8: Remove a Route"); System.out.println("\t9: Add a City"); System.out.println("\t10: Remove a City"); System.out.println("\t11: Quit"); System.out.println("\t12: Quit Without Saving"); System.out.print("Enter numeric choice: "); int choice = input.nextInt(); input.nextLine(); // throw out leftover newline switch (choice) { case 1: a.showAllRoutes(); break; case 2: a.mst(); break; case 3: System.out.print("Enter the first city: "); city1 = input.nextLine(); System.out.print("Enter the second city: "); city2 = input.nextLine(); a.shortestByDistance(city1, city2); break; case 4: System.out.print("Enter the first city: "); city1 = input.nextLine(); System.out.print("Enter the second city: "); city2 = input.nextLine(); a.shortestByCost(city1, city2); break; case 5: System.out.print("Enter the first city: "); city1 = input.nextLine(); System.out.print("Enter the second city: "); city2 = input.nextLine(); a.shortestByHops(city1, city2); break; case 6: System.out.print("Enter max cost: "); double cost = input.nextInt(); a.pathsUnderCost(cost); break; case 7: System.out.print("Enter the first city: "); city1 = input.nextLine(); System.out.print("Enter the second city: "); city2 = input.nextLine(); System.out.print("Enter the distance: "); int distance = input.nextInt(); System.out.print("Enter the price: "); double price = input.nextDouble(); a.addRoute(city1, city2, distance, price); break; case 8: System.out.print("Enter the first city: "); city1 = input.nextLine(); System.out.print("Enter the second city: "); city2 = input.nextLine(); a.removeRoute(city1, city2); break; case 9: System.out.print("Enter the city name: "); city1 = input.nextLine(); a.addCity(city1); break; case 10: System.out.print("Enter the city name: "); city1 = input.nextLine(); a.removeCity(city1); break; case 11: a.saveRoutes(filename); break loop; case 12: break loop; } } }