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

  • Home
  • SEARCH
  • 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 7624161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:53:24+00:00 2026-05-31T04:53:24+00:00

I’m probably missing something very simple but I’m new and it’s just easier to

  • 0

I’m probably missing something very simple but I’m new and it’s just easier to ask for help. This is homework so you can give clues if you want but please understand I’m horrible at java.

Below is some code for an address book. I want the user to enter 1 to view the entries 2 to put another entry in the book or 3 to quit.
I got the program to work but it didn’t loop to ask the user what to do next. I then coded a switch statement and when the user selects 1 the program doesn’t run the code associated with case 1: and it’s the same with case 2. The program does validate my entry (I wrote a validator in a seperate class)

Did I miss something when coding it?

again I’m new so don’t beat me up.

    import java.util.Scanner;

    public class AddressBookEntryApp 
    {

public static void main(String[] args) 
{

    //create new scanner
    Scanner ip = new Scanner(System.in);
    //welcome user to the address book application
    System.out.println("Welcome to the Address Book Application");
    System.out.println();
    int choice = 0;
    boolean quit = false;
    do
    {

        //have the user enter a menu number
        System.out.println("1 - List entires");
        System.out.println("2 - Add entry");
        System.out.println("3 - Exit");


        System.out.println();
        int menuNumber = Validator.getInt(ip, "Enter menu number: ", 1, 3);
        System.out.println();
        switch (choice)
        {
        case 1:

                AddressBookIO GetEntryObject = new AddressBookIO();
                GetEntryObject.getEntriesString();
                System.out.println(AddressBookIO.getEntriesString());
                break;

        case 2:


                String name = Validator.getEntry(ip, "Enter name: ");
                String email = Validator.getEntry(ip, "Enter email address");
                String phone = Validator.getEntry(ip, "Enter phone number: ");
                AddressBookEntry newEntry = new AddressBookEntry(name, email, phone);
                AddressBookIO.saveEntry(newEntry);
                break;


        }
}while (!quit);

    }
    }
  • 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-31T04:53:26+00:00Added an answer on May 31, 2026 at 4:53 am

    You don’t change the value of variable choice. Therefore it remains ‘0’ as you initialized at the beginning. So your code never gets into the case statements. That’s the problem . Try the following:

    choice = Validator.getInt(ip, "Enter menu number: ", 1, 3);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.