Hi!
I'm quite a Java newb and doing a college assignment. I was just wondering if anyone could show me how to ask the user if they want to return to the main menu screen. Either ask the user if they want to, or just have it print out after each menuoption "Type [KEY] to return to main menu". Something simple... Here's my code:
import java.util.Scanner; /** PROGRAMMING FUNDAMENTALS ASSIGNMENT 2009 * Designing a program to record Taxi stuff */ class C22Taxis { public static void main(String [] args) { Scanner input = new Scanner(System.in); int menuin; int menuoption = 0; int selecttaxi = 0; String [] taxi = new String[3]; String [] dest = new String[3]; String [] name = new String[3]; String [] service = new String[3]; System.out.println("Welcome to C22 Taxis Menu"); System.out.println("Select an option/number"); System.out.println(""); System.out.println("1) Change Taxi Booking State"); System.out.println("2) Change Taxi Serviceability"); System.out.println("3) Enter/Change Taxi Driver's Name"); System.out.println("4) List All Taxi Details"); System.out.println(" (Taxi number, driver, serviceability and availability)"); System.out.println(""); menuoption = input.nextInt(); // BOOKING STATE - OPTION 1 if (menuoption == 1) { System.out.println('\f'); System.out.println("C22Taxi's Booking State Log"); System.out.println(""); System.out.print("Enter taxi number: "); selecttaxi = input.nextInt(); { if (selecttaxi == 1) { System.out.print("Enter destination for Taxi " + selecttaxi + " (if none enter NONE): "); dest[0] = input.next(); } else if (selecttaxi == 2) { System.out.print("Enter destination for Taxi " + selecttaxi + " (if none enter NONE): "); dest[1] = input.next(); } else if (selecttaxi == 3) { System.out.print("Enter destination for Taxi " + selecttaxi + " (if none enter NONE): "); dest[2] = input.next(); } } } // TAXI SERVICEABILITY - OPTION 2 if (menuoption == 2) { System.out.println('\f'); System.out.println("C22Taxi's Serviceability Log"); System.out.println(""); System.out.print("Enter taxi number: "); selecttaxi = input.nextInt(); { if (selecttaxi == 1) { System.out.print("Has Taxi " + selecttaxi + " the taxi been serviced? (Yes/No): "); service[0] = input.next(); System.out.println("Current service state for Taxi " + selecttaxi + ": " + service[0]); } else if (selecttaxi == 2) { System.out.print("Has Taxi " + selecttaxi + " the taxi been serviced? (Yes/No): "); service[1] = input.next(); System.out.println("Current service state for Taxi " + selecttaxi + ": " + service[1]); } else if (selecttaxi == 3) { System.out.print("Has Taxi " + selecttaxi + " the taxi been serviced? (Yes/No): "); service[2] = input.next(); System.out.println("Current service state for Taxi " + selecttaxi + ": " + service[2]); } } } // TAXI DRIVER NAME - OPTION 3 if (menuoption == 3) { System.out.println('\f'); System.out.println("C22Taxi's Driver Log"); System.out.println(""); System.out.print("Enter taxi number: "); selecttaxi = input.nextInt(); { if (selecttaxi == 1) { System.out.print("Enter current/new driver for Taxi " + selecttaxi + ": "); name[0] = input.next(); System.out.println("Taxi " + selecttaxi + " current driver: " + name[0]); } else if (selecttaxi == 2) { System.out.print("Enter current/new driver for Taxi " + selecttaxi + ": "); name[1] = input.next(); System.out.println("Taxi " + selecttaxi + " current driver: " + name[1]); } else if (selecttaxi == 3) { System.out.print("Enter current/new driver for Taxi " + selecttaxi + ": "); name[2] = input.next(); System.out.println("Taxi " + selecttaxi + " current driver: " + name[2]); } } } // TAXI VEHICLE DETAILS - OPTION 3 if (menuoption == 4) { System.out.println('\f'); System.out.println("C22Taxi's Vehicle Details"); System.out.println(""); System.out.print("Enter taxi number: "); selecttaxi = input.nextInt(); { if (selecttaxi == 1) { System.out.println("Taxi Infomation"); System.out.println("-----------------"); System.out.println("Number: " + selecttaxi); System.out.println("Driver: " + name[0]); System.out.println("Serviceability: " + service[0]); System.out.println("Availability: " + dest[0]); } else if (selecttaxi == 2) { System.out.println("Taxi Infomation"); System.out.println("-----------------"); System.out.println("Number: " + selecttaxi); System.out.println("Driver: " + name[1]); System.out.println("Serviceability: " + service[1]); System.out.println("Availability: " + dest[1]); } else if (selecttaxi == 3) { System.out.println("Taxi Infomation"); System.out.println("-----------------"); System.out.println("Number: " + selecttaxi); System.out.println("Driver: " + name[2]); System.out.println("Serviceability: " + service[2]); System.out.println("Availability: " + dest[2]); } } } // END OF OPTIONS } }
Any help would be useful. Thanks.