Hi,
The code looks right. Do you have both projects open in netBeans,
that is, the example code and the lab? If so, check which one is
the main project. (It will be in bold face.) If you run the project
by clicking on the arrow icon in the bar on top, it will always run
the main project.
You can do one of two things:
1. Right-click on the homework project name and click Run in the
popup menu.
2. Right-click on the homework project name and clice Set as Main
Project
in the popup menu. Then when you click on the arrow icon, the
homework
project will run.
Please let us know if this is what is happening, or if something else
is going on. Thanks!
Jim
On Jan 18, 2:37 am, [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
-~----------~----~----~----~------~----~------~--~---