uNreQuiteD

January 9, 2007

selection structure – if

Filed under: basic java — anai lem @ 9:58 am

import javax.swing.JOptionPane;
class selectStruct
{
public static void main(String args[])
{
int choice;
String str;
str = JOptionPane.showInputDialog(“Main Menu \n” +
                                  “[1] Name \n” +
                                  “[2] School \n” +
                                  “[3] Course \n” +
                                  “[4] Exit”);
choice =Integer.parseInt(str);
if(choice ==1)
  JOptionPane.showMessageDialog(null, “iana mel f. galang”);
else if(choice ==2)
  JOptionPane.showMessageDialog(null, “DWCL”);
else if(choice ==3)
  JOptionPane.showMessageDialog(null, “Business Administration”);
else if(choice ==4)
  JOptionPane.showMessageDialog(null, “by: Eugene”);
}
}

output

in.jpg

Create a free website or blog at WordPress.com.