0

My programming assignment asks that we print a menu system, take in user input then to keep re printing the menu system until a Break key is struck. I've gotten an unreachable code error that I've never seen before where I've inserted the comment.

import java.util.Scanner;
public class SkillsDemo02 {

public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while (true) {
    System.out.println("______________________________");
    System.out.println("Welcome to the Voting Register");
    System.out.println("");
    System.out.println("Please Select one of the following:");
    System.out.println("1. Add a name to the Register");
    System.out.println("2. Search for a name on the register");
    System.out.println("3. Delete a name from te register");
    System.out.println("4. View all names on the register");
    System.out.println("");
    System.out.println("0. Exit");
    System.out.println("______________________________");
    int firstChoice = sc.nextInt();
    }
// int choice = sc.nextInt(); 
    if (choice == 1) {
        String names [] = new String [10];
        System.out.println("You have chosen option 1, to add a name to the register");
        System.out.println("Please enter your chosen name");
        String user = sc.nextLine();
        String user2 = sc.nextLine();
        System.out.println(user2);
        sc.close();
    }

}

}
kryger
  • 12,906
  • 8
  • 44
  • 65
Marcus
  • 1

0 Answers0