Monday, 5 October 2015

Java Program that finds the Age of a person

/**
 *
 */

/**
 *
 *
 */
public class PersonAge {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

Age a = new Age(10);
a.check();
}
}



public class Age {
private int a;
Age(int i){
a=i;
}
void check(){
if(a<=20)System.out.println("She/He is below 20");
else if((a>20) && (a<50))
System.out.println("She/He is between 20 and 50");
else
System.out.println("She/He is above 50");
}
}

Output:-
She/He is below 20

No comments:

Post a Comment