forked from Nabin-joshi/java_notes_and_programs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Condition.java
32 lines (30 loc) · 913 Bytes
/
Condition.java
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 java.sql.SQLOutput;
import java.util.Scanner;
public class Condition {
public static void main(String[] args) {
int age,pwd;
String name;
System.out.println("Enter age ");
Scanner sc = new Scanner(System.in);
age=sc.nextInt();
name = sc.nextLine();
System.out.println(name);
if (age>18){
System.out.println("You are Logged in");
name = sc.nextLine();
System.out.println(name);
} else if (age==18) {
System.out.println("Enter Password");
pwd=sc.nextInt();
if (pwd==123){
System.out.println("elseIf 1");
}else{
System.out.println("nested");
}
} else if (age<=15 && age>=19) {
System.out.println("elseIF 2");
}else {
System.out.println("else");
}
}
}