Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7610927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:32:15+00:00 2026-05-31T01:32:15+00:00

I’ve set up a menu that prints to console. Takes user input, calls according

  • 0

I’ve set up a “menu” that prints to console. Takes user input, calls according method, and then should return to the menu for further instruction. How should I structure my code so that it outputs the “menu” after it’s done doing whatever it’s doing?

public static void main(String[] args)throws Exception {
    // TODO Auto-generated method stub
    Scanner keyboard = new Scanner(System.in);
    EntryNode n = new EntryNode();
    AddressList addressBook = new AddressList();

    String menu = " ";

    System.out.println("******************************************************************");
    System.out.println("Welcome to the Jackie 2000 Address Book");
    System.out.println("What do you want to do? ");
    System.out.println("[p] View All Entries in Address Book  [a] Add New Entry");
    System.out.println("[d] Remove An Entry                   [s] Search for Entry");
    System.out.println("[i] Import Address Book               [x] Export Address Book");
    System.out.println("[z] Exit");

    System.out.println();
    System.out.println("Please enter your choice: ");
    menu = keyboard.next().toLowerCase();

    if (menu.equals("p")) {
        try {
            addressBook.printList();
        }
        catch (Exception e){

        }
    }
    else if (menu.equals("a")) {
        System.out.println("Enter in the first name ");
        String firstName = keyboard.next().toUpperCase();
        System.out.println("Enter in the last name ");
        String lastName = keyboard.next().toUpperCase();
        System.out.println("Enter in the phone number");
        String phoneNum = keyboard.next().toUpperCase();
        System.out.println("Enter in the email");
        String email = keyboard.next().toUpperCase();
        addressBook.addEntry(firstName,lastName,phoneNum,email);
    }
    else if (menu.equals("d")) {
        EntryNode temp = head;
        for (int i = 0; i <addressBook.length(); i++) {
            System.out.println(i + " Name: " + temp.getFirstName() + " " + temp.getLastName() + " " 
        + temp.getPhoneNum() + " " + temp.getEmail());
            temp = temp.getNext();
        }
        System.out.println(" ");
        System.out.println("Please enter the index of the entry you wish to delete ");
        int index = keyboard.nextInt();
        addressBook.removeEntry(index);
    }

    else if (menu.equals("s")) {
        System.out.println("Do you want to search by email or name? ");
        String decision = keyboard.next();
        if (decision.equals("email")) {
            System.out.println("What email address are you looking for? ");
            String email = keyboard.next();
            addressBook.searchEmail(email);
        }
        else if (decision.equals("name")) {
            System.out.println("What name are you looking for?");
            String name = keyboard.next();
            addressBook.searchEntry(name);
        }
        else System.out.println("Invalid entry. Type in 'email' or 'name'");
    }

    else if (menu.equals("i")) {
        addressBook.importBook();
    }

    else if (menu.equals("x")) {
        addressBook.exportBook();
    }

    else if (menu.equals("e")) {
        System.exit(0);
    }
    else {
        System.out.println("Invalid Entry");
    }
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:32:16+00:00Added an answer on May 31, 2026 at 1:32 am

    You should definitely take a look at java’s switch statement: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html

    You could have the entire switch-case statement inside a while loop with a boolean for when it should exit. For example:

    while(!exit){
        switch(input){
             case "a": do something;break;
             case "d":...
             ...
             case "e": exit = true;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.