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);
}
}