Asks how you are feeling, inputs an answer, then responds to the answer. Understands "fine" and "sick", but nothing else.
String answer = showInputDialog(this,"How are you today?");
Inputs the users answer, and stores it in the answer variable.
if ( answer.equals("sick") )
Checks whether answer is equal to "sick".
showMessageDialog(this,"Sorry to hear that..."); }
Displays a message.
Comments
The Dialog commands only work because the class extends JOptionPane. Normally the program extends JFrame. Then these commands must be written like this:
name=
JOptionPane.showInputDialog(this,"Name?");
JOptionPane.showMessageDialog(this,"Hello");