-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDays.java
64 lines (61 loc) · 1.72 KB
/
Days.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import java.util.Scanner;
public class Days {
public static void main (String[] args){
Scanner s = new Scanner(System.in);
System.out.println("Enter today's date:");
System.out.println("0 = Sunday, 1 = Monday, etc...");
String current = s.nextLine();
System.out.println("Enter the number of days elapsed since today:");
String future = s.nextLine();
int cd = Integer.parseInt(current);
int fd = Integer.parseInt(future);
fd = (cd + fd) % 7;
switch (cd) {
case 0:
current = "Sunday";
break;
case 1:
current = "Monday";
break;
case 2:
current = "Tuesday";
break;
case 3:
current = "Wednesday";
break;
case 4:
current = "Thursday";
break;
case 5:
current = "Friday";
break;
case 6:
current = "Saturday";
break;
}
switch (cd) {
case 0:
future = "Sunday";
break;
case 1:
future = "Monday";
break;
case 2:
future = "Tuesday";
break;
case 3:
future = "Wednesday";
break;
case 4:
future = "Thursday";
break;
case 5:
future = "Friday";
break;
case 6:
future = "Saturday";
break;
}
System.out.println("Today is " + current + " and the specified future date is " + future + ".");
}
}