I have written this program, a menu with a switch. When any of the options have been executed, except from 11 (End), I would like to get the menu displayed again. Now, when I run the program it stops after the task is finished. I have to run the program again, and my list is empty.
Any suggestions?? Thank you
package oblig1;
import java.util.Scanner;
class Menu {
public static void main(String[] args) {
SingleLink l = new SingleLink();
String [] options = {
"Delete an element first in the list",
"Add an element in the end of list",
"Delete an element in the end of list",
"Delete an element with given value from the list",
"Add an element after an element with given value",
"Add an element in front of an element with given value",
"Print the length of the list",
"Count Number of elements with given value in the list, \n\tand print the Number ofelement",
"Print the whole list",
"Delete whole list",
"End"
};
System.out.println("What would you like to do? \n");
for (int i = 0; i < options.length; i++) {
System.out.println((i+1) + ":\t" + options[i] + " ");
}
Scanner input = new Scanner(System.in);
int option= input.nextInt();
while (option != 11)
switch(option) {
case 1:
l.remove(null);
break;
case 2:
System.out.println("What value should the element have? ");
int value = input.nextInt();
l.insertLast(value);
break;
case 9:
//
break;
case 10:
l.findSize();
int a = l.findSize();
l.deleteAll();
System.out.println("Number of elements Deleted : " + a);
break;
case 11:
}
}
}