My assignment is to create a program that asks the user what they want to do: 1-add a member, 2-delete a member, 3-see the arraylist of members, or 4- exit. I have the menu popping up, but I can't get it to go back to the menu after I execute the program once. It needs to keep going until the user enters quit. I've tried everything I can think of. Help please?
public class MemberList
{
public static void main(String[] args)
{
boolean cont = false;
ArrayList<String> mymembers;
mymembers = new ArrayList<String>();
String myS;
double option;
myS = JOptionPane.showInputDialog(
null,
"Please choose:" +
"\n 1-Add a new Member." +
"\n 2-Delete by name."+
"\n 3-Display All"+
"\n 4-Quit",
"Member List",
JOptionPane.PLAIN_MESSAGE);
option = Double.parseDouble(myS);
while (cont)
{
if(option==1)
{
String name =
JOptionPane.showInputDialog(
null,
"Please enter a member name to add.",
"Add",
JOptionPane.PLAIN_MESSAGE);
mymembers.add(name);
}
else if (option==2)
{
String delete =
JOptionPane.showInputDialog(
null,
"Please enter a name to delete.",
"Delete",
JOptionPane.PLAIN_MESSAGE);
mymembers.remove(delete);
cont=true;
}
else if (option==3)
{
int n = mymembers.size();
for(int i = 0; i < n ; i++)
System.out.println( mymembers.get( i ) );
cont=true;
}
else if (option==4)
{
cont=false;
}
}
System.exit(0);
}
}