forked from SaketJNU/Java-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeekday.java
More file actions
43 lines (40 loc) · 842 Bytes
/
Weekday.java
File metadata and controls
43 lines (40 loc) · 842 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
33
34
35
36
37
38
39
40
41
42
43
//Program that keeps a number from the user and generates an integer between 1 and 7 and displays the name of the weekday.
import java.util.Scanner;
public class Weekday
{
public static void main(String args[])
{
Scanner reader = new Scanner(System.in);
System.out.print("Please eneter a number: ");
int num = reader.nextInt();
int rem = num %7;
if (rem == 0)
{
System.out.print("\nIt is Sunday");
}
else if (rem == 1)
{
System.out.print("\nIt is Monday");
}
else if (rem == 2)
{
System.out.print("\nIt is Tuesday");
}
else if (rem == 3)
{
System.out.print("\nIt is Wednesday");
}
else if (rem == 4)
{
System.out.print("\nIt is Thursday");
}
else if (rem == 5)
{
System.out.print("\nIt is Friday");
}
else if (rem == 6)
{
System.out.print("\nIt is Saturday");
}
}
}