Hi
I have a problem with a switch case meny. As selection number 5 the program will quit. I have built the meny in a do while loop that will run as long as menyChoise isnīt equal to "5", but it does not end. Please help me and explain whats wrong.
import java.util.Scanner; public class UI { public static void main(String[] args) { String menyChoise = null; do { for (int x=1; x<50; x++) { System.out.println(" "); } System.out.println("Welcome to Landegrens Hotel service."); System.out.println("1. List Availible Rooms"); System.out.println("2. List Booked Rooms"); System.out.println("3. Check In Person"); System.out.println("4. Check Out Person"); System.out.println("5. Quit"); System.out.print("Please choose what you want to do by entering number:"); Scanner scan = new Scanner(System.in); menyChoise = scan.nextLine(); switch (menyChoise) { case "1": System.out.println("You want to list all availible rooms"); try { Thread.sleep(2000); } catch(InterruptedException ex) { Thread.currentThread().interrupt(); } break; case "2": System.out.println("You want to list booked rooms"); try { Thread.sleep(2000); } catch(InterruptedException ex) { Thread.currentThread().interrupt(); } break; case "3": System.out.println("You want to Check In a person"); try { Thread.sleep(2000); } catch(InterruptedException ex) { Thread.currentThread().interrupt(); } break; case "4" : System.out.println("You want to check out a person"); try { Thread.sleep(2000); } catch(InterruptedException ex) { Thread.currentThread().interrupt(); } break; case "5" : System.out.println("Quiting Program. Se Yaah"); try { Thread.sleep(2000); } catch(InterruptedException ex) { Thread.currentThread().interrupt(); } break; default: System.out.println("Please choose a menynumber from 1-5"); try { Thread.sleep(2000); } catch(InterruptedException ex) { Thread.currentThread().interrupt(); } break; } }while (menyChoise != "5"); } }