-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise03_05.java
More file actions
64 lines (60 loc) · 2.18 KB
/
Copy pathExercise03_05.java
File metadata and controls
64 lines (60 loc) · 2.18 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package Chapter3;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.Scanner;
/**
*
* @author jorda
*/
public class Exercise03_05 {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Enter the day of the week (Sunday is 0): ");
int currentDay = input.nextInt();
System.out.print("Enter the number of days into the future to calculate: ");
int daysToAdvance = input.nextInt();
int futureDay = (currentDay + daysToAdvance) % 7;
//System.out.println("DEBUG: " + futureDay);
String sCurrentDay, sFutureDay;
if(currentDay == 0)
sCurrentDay = "Sunday";
else if (currentDay == 1)
sCurrentDay = "Monday";
else if (currentDay == 2)
sCurrentDay = "Tuesday";
else if (currentDay == 3)
sCurrentDay = "Wednesday";
else if (currentDay == 4)
sCurrentDay = "Thursday";
else if (currentDay == 5)
sCurrentDay = "Friday";
else if (currentDay == 6)
sCurrentDay = "Saturday";
else{
System.out.println("ERROR: The current day was not inputted correctly, The results will not be correct!");
sCurrentDay = "ERROR";
}
if(futureDay == 0)
sFutureDay = "Sunday";
else if (futureDay == 1)
sFutureDay = "Monday";
else if (futureDay == 2)
sFutureDay = "Tuesday";
else if (futureDay == 3)
sFutureDay = "Wednesday";
else if (futureDay == 4)
sFutureDay = "Thursday";
else if (futureDay == 5)
sFutureDay = "Friday";
else if (futureDay == 6)
sFutureDay = "Saturday";
else{
System.out.println("ERROR: The future day was not inputted correctly, The results will not be correct!");
sFutureDay = "Error";
}
System.out.println("Today is " + sCurrentDay + " and the future day is " + sFutureDay);
}
}