-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIfStatement.java
More file actions
32 lines (26 loc) · 843 Bytes
/
IfStatement.java
File metadata and controls
32 lines (26 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import com.sun.nio.sctp.SctpSocketOption;
import java.util.Scanner;
public class IfStatement {
public static void main(String[] args) {
// if statement = performs a block of code if its condition is true
Scanner sc = new Scanner(System.in);
int age;
System.out.print("Enter your age: ");
age = sc.nextInt();
if (age >= 18) {
System.out.println("You are an Adult");
}
else if (age > 65) {
System.out.println(" You are senior");
}
else if (age < 0) {
System.out.println(" You Haven't been born yet");
}
else if (age == 0) {
System.out.println(" You are a baby");
}
else {
System.out.println("You are a child");
}
}
}