program to check given age is kids, Teen ager , Adult or senior citizen
Program to check if user enter age then print you are kid or
Teen ager or Adult or senior citizen. In this program used && (logical And) operator and if else
control Structures.
// program to check
given age is kids, Teen ager , Adult or senior citizen
import
java.util.Scanner;
class
Agecheck{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.println("Plz Enter age:");
int ag = sc.nextInt();
if(ag<10){
System.out.println("you are kid.");
}
else if (ag>=10&&ag<=17){
System.out.println("you are Teen ager");
}
else if(ag>=18&&ag<=55){
System.out.println("you are Adult");
}
else
System.out.println("you
are senior citizen");
}
}
Save program with .java extension: program_name.java
Program_name always should main class name
For compile :
Open cmd and goto your file and type command
Javac Agecheck.java
For Run:
Java Agecheck
Output:
0 comments: