Trying to do the homework for Lab-1004, I took the code from the first
MyInputKeyboardJOptionPane to adapt as suggested for the homework.
Instead of only offering the option of age input which seems that it
would fill the requirements, I tried to keep the option of entering
name then age with an if/else to determine output.
String name="";
String age="";
name=JOptionPane.showInputDialog("Please enter your name");
age=JOptionPane.showInputDialog("Please enter your age");
int ageint=Integer.parseInt(age);
if(ageint>100){
String msg="Hello "+name+", you are old!";
JOptionPane.showMessageDialog(null, msg);
}else{
String msg="Hello "+name+", you are young!";
JOptionPane.showMessageDialog(null, msg);
Builds fine with netbeans 6.1, when run:
1. Asks for Name input
2. Asks for Age input
However, instead of Giving an expected output of "Hello <name>, you
are old(young)!, it is only giving Hello<name>! as the example code
did through the lab.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---