Hi,
I have a system that contain switch statement, my problem is with the X choice when the user exits the system, how can I write a code that exits the system while printing a message say: Exiting system.
Thanks
Printable View
Hi,
I have a system that contain switch statement, my problem is with the X choice when the user exits the system, how can I write a code that exits the system while printing a message say: Exiting system.
Thanks
hmm, how about print the message first, then exit the system?
yes, sorry, that is what I want to do, to print a message and then exit the system
here is what I have done:
I don't what else to put in the exit method to exit completely.Code:public void select()
{ char action = readAction();
execute(action);
action = readAction(); }
private char readAction()
{ System.out.print("\tEnter action (A/X): ");
return In.nextLine().toUpperCase().charAt(0);}
private void execute(char action)
{ switch(action)
{case 'A' : add(); break;
case 'X' : exit(); break
default: System.out.println("\t\tInvalid action");}}
private void exit()
{
S.o.p("exiting the system");
}
search for joptionpane
How to Make Dialogs (The Java™ Tutorials > Creating a GUI with JFC/Swing > Using Swing Components)
for popup message
if use console, command line, use system.out.println(exit_msg);
exit the program
System (Java 2 Platform SE 5.0)
System.exit(0);
Do you want the message to be printed and displayed and the system to wait until the user has entered a key to exist the system?