Hi all

I have been trying to work it out all day but output error displays the 
following : 

 

run:
Exception in thread "main" java.lang.NumberFormatException: For input string: 
"Your age is 10"
        at 
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
        at java.lang.Integer.parseInt(Integer.java:449)
        at java.lang.Integer.parseInt(Integer.java:499)
        at 
GetInputFromKeyboardJOptionPane2.main(GetInputFromKeyboardJOptionPane2.java:28)
Java Result: 1
BUILD SUCCESSFUL (total time: 7 seconds)

 

This is my program code:

 

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import javax.swing.JOptionPane;


/**
 *
 * @author Compuline
 */
public class GetInputFromKeyboardJOptionPane2 {
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        String name = "";
        name = JOptionPane.showInputDialog ("Please enter your name");
        String msg = "Hello " + name + "!";
        JOptionPane.showMessageDialog (null, msg);

 

        String age = "";
        age = JOptionPane.showInputDialog ("Please enter your age");
        age = "Your age is " + age;
        JOptionPane.showMessageDialog (null, age);

 

        int ageint = Integer.parseInt(age);
        if (ageint>100){
            age = "Hello"+name+"Your age is"+age+"You are old";
            JOptionPane.showMessageDialog(null,age);
        }else{
            age = "Hello"+name+"Your age is"+age+"You are young";
            JOptionPane.showMessageDialog(null,age);
        }


     
        }
    }

 

cAN SOMEONE PLS HELP ME, AM I MISSING ON SOMETHING HERE ? 


 

_________________________________________________________________
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/
--~--~---------~--~----~------------~-------~--~----~
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