import javax.swing.JOptionPane;
import java.util.Scanner;
public class CodeWithProblem
{
public static void main (String[] args)
{
String name, gender, passions, enjoy;
int yesNo, permission, endProgram;
String prefix = "";
while (true)
{
name = JOptionPane.showInputDialog("Please enter your name: ","Name");
if (name.equals("null"))
{
System.exit(0);
}
yesNo = JOptionPane.showConfirmDialog(null, "So your name is "+name+". Is this correct?", "", JOptionPane.YES_NO_OPTION);
if (yesNo == -1)
{
System.exit(0);
}
if (yesNo == 0)
{
break;
}
}
while (true)
{
gender = JOptionPane.showInputDialog("Are you a boy or a girl?: ");
if (gender.equals("null"))
{
System.exit(0);
}
if ("boy".equalsIgnoreCase(gender)||"girl".equalsIgnoreCase(gender))
{
break;
}
}
if ("boy".equalsIgnoreCase(gender))
{
prefix = "Mr. ";
}
if ("girl".equalsIgnoreCase(gender))
{
prefix = "Ms. ";
}
JOptionPane.showMessageDialog(null, "It's nice to meet you "+prefix+name+".", "Hello", JOptionPane.PLAIN_MESSAGE);
permission = JOptionPane.showConfirmDialog(null, "Lets ask some easy questions to start out with. Is this okay with you?: ",
"", JOptionPane.YES_NO_OPTION);
if (permission == 1)
{
endProgram = JOptionPane.showConfirmDialog(null, "Do you want to end this program? Click CANCEL to end and OKAY to continue.",
"End Program?", JOptionPane.OK_CANCEL_OPTION);
if (endProgram == 0)
{
JOptionPane.showMessageDialog(null, "Good, lets continue...", "Continue", JOptionPane.PLAIN_MESSAGE);
permission = 0;
}
if (endProgram == 1)
{
JOptionPane.showMessageDialog(null, "Goodbye....", "END", JOptionPane.PLAIN_MESSAGE);
}
}
if (permission == 0)
{
passions = JOptionPane.showInputDialog("What are some of your passions?: ");
if (passions.equals("null"))
{
System.exit(0);
}
enjoy = JOptionPane.showInputDialog("Why do you enjoy "+passions+"?: ");
if (enjoy.equals("null"))
{
System.exit(0);
}
JOptionPane.showMessageDialog(null, "That's interesting", "hmmm", JOptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog(null, "This program has no point and is going to end now.", "BACON", JOptionPane.PLAIN_MESSAGE);
}
}
}
Tuesday, 23 January 2018
Related Posts:
Swing UI example in java import java.awt.Color;import java.awt.BorderLayout;import java.awt.eve… Read More
Calculator in java package calculation.twovar;public class DIFFERENCE{ &… Read More
drawing of circle in java Drawing of circle in java package geometry.drawing;public class Cir… Read More
Java Interface Example in java/*Java Interface example.This Java Interface example describes how int… Read More
0 comments: