Hello,

The code looks fine. You might have run the example project instead.
Check to see if you build and run the right project.

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
[email protected]
Sent: Sunday, January 18, 2009 3:37 AM
To: Free Java Programming Online Training Course By Sang Shin
Subject: [java programming] Lab-1004 JOptionPane showing same as example
code


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
-~----------~----~----~----~------~----~------~--~---

Reply via email to