Tuesday, August 18, 2015

How to write an if construct in java

User Interface:

Code written on the event of Check age Button:

int age;

age=Integer.parseInt(jTextField1.getText());

if(age<=0)
{
    jLabel2.setText("ERROR");
}
else
{
    if(age>0 && age<=50 )
    {
        jLabel2.setText("Young Age");
    }
    else
    {
        jLabel2.setText("Old Age");
    }
}



No comments: