How do I go about writing a loop that's supposed to be boolean, yet the answer can be an integer using JOptionPane
?
boolean promptMenu( int menu )
- This will represent the core of your code.
- Should be in the body of a loop inside
main()
.- Returns true if it should continue running.
- Returns false if it is time to quit.
- Notice that
promptMenu
takes in anint
parameter: 0 - Prints the Main Menu.
So far this is what I got:
import javax.swing.JOptionPane;
public class BankSystem {
//Fields
static boolean question = true;
static String q ;
static int qt;
//Methods
public static void main(String[]args)
{
while(question = true)
{
promptMenu (qt) ;
}
}
static int promptMenu( int qt )
{
q = JOptionPane.showInputDialog ("Gen's Bank" + "\n \n Print main menu? 0-> YES\n\n") ;
qt = Integer.parseInt(q);
if (qt != 0)
{
question = false;
}
return (qt);
}
}
If you press anything that isn't 0 it still loops. Any Suggestions would help.