forked from examplehub/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIfElseifElse.java
More file actions
40 lines (35 loc) · 1.06 KB
/
IfElseifElse.java
File metadata and controls
40 lines (35 loc) · 1.06 KB
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
36
37
38
39
40
package com.examplehub.basics;
import java.util.Scanner;
public class IfElseifElse {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Please input a number:");
int number = scanner.nextInt();
if (number > 0) {
System.out.println(number + " is positive number");
} else if (number < 0) {
System.out.println(number + " is negative number");
} else {
System.out.println("input is zero");
}
System.out.println("Please input a day:");
int day = scanner.nextInt();
if (day == 1) {
System.out.println("Monday");
} else if (day == 2) {
System.out.println("Tuesday");
} else if (day == 3) {
System.out.println("Wednesday");
} else if (day == 4) {
System.out.println("Thursday");
} else if (day == 5) {
System.out.println("Friday");
} else if (day == 6) {
System.out.println("Saturday");
} else if (day == 7) {
System.out.println("Sunday");
} else {
System.out.println("Invalid day");
}
}
}