I am having some issue while using scanner class for some menu of choices from keyboard I am trying to execute below logic from main method
StudentBO country = new StudentBO();
Scanner sc = new Scanner(System.in);
int selection;
System.out.println("Menu : ");
System.out.println("Type any number between 1 and 6");
System.out.println("1)Create a new student");
System.out.println("2)details specific student");
System.out.println("3)details of all students");
System.out.println("4)details of the student age details");
System.out.println("5)details of the student personal info");
System.out.println("6)Exit");
selection = sc.nextInt();
switch (selection)
{
case 1 :
System.out.println("Enter studentName ");
sc = new Scanner(System.in);
String studentName= sc.nextLine();
Student studentInfo = student.createStudent(studentName);
System.out.println("Do you want to continue? Type Yes / No");
Scanner sc1 = new Scanner(System.in);
case 2 :
break;
case 3 :
break;
case 4 :
break;
case 5 :
break;
case 6 :
break;
}
When i am selecting choice 1, student is created, and then i have to enter Yes or No, if user selected yes, again user to be prompted from menu of choices (1,2,3,4,5 or 6), if user selected No, then break.
issues i am facing
How to go back to select menu of choices after execution of one case. I want to go back to prompt user with menu of choices after case 1
How to switch from one case to another. in case 1, based on some if condition, I want to call case 2 directly. is that possible?