-
Notifications
You must be signed in to change notification settings - Fork 13
/
IfElseExample.java
35 lines (26 loc) · 954 Bytes
/
IfElseExample.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
33
34
35
package lessons.flowcontrol.ifelse;
public class IfElseExample {
public static void main(String[] args)
{
java.util.Scanner keyboard = new java.util.Scanner(System.in);
System.out.print("First number: ");
int firstNumber = keyboard.nextInt();
System.out.print("Second number: ");
int secondNumber = keyboard.nextInt();
// First > Second
if (firstNumber > secondNumber) {
System.out.println("First number > Second Number");
}
System.out.print("Yasin age: ");
int yasinAge = keyboard.nextInt();
if (yasinAge >= 18) {
System.out.print("Do you have girlfriend ? ");
boolean hasGirlFriend = keyboard.nextBoolean();
if (hasGirlFriend) {
System.out.println("You can enter the disco");
} else {
System.out.println("You cant enter");
}
}
}
}