Shapecha:
I took your piece of code, and pasted in a project (netbeans 6.5),
and it work as you expected.
Are you sure you are running the project with this code? (Maybe
you are running another project in the same Projects Pane, or you
didn't save the code before you build and run the project.
Note: You forgot the brace "}" at the end of code, but I think this
isn't the problem.
On 18 ene, 06:37, [email protected] wrote:
> 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
-~----------~----~----~----~------~----~------~--~---