-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOurDate.java
More file actions
56 lines (44 loc) · 1.33 KB
/
OurDate.java
File metadata and controls
56 lines (44 loc) · 1.33 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
package assign2;
import java.util.Scanner;
/* Name: Adam Mohr
* Section: 301
* Lab Teacher: Jason Mombourquette
* Purpose of Program: Calculate the difference between two given dates using classes and if statements.
* Assignment Number #2
* Date: Friday, March 16th 2018
*/
public class OurDate {
private int month, day, year; // Declare variables.
private Scanner input = new Scanner (System.in);
public OurDate () { // Default constructor.
year = 2000;
month = 1;
day = 1;
}
public OurDate (int y, int m, int d) { // Parameterized initial constructor.
year = y;
month = m;
day = d;
}
public void inputDay () { // Receive input for day.
System.out.print("Enter a day: ");
day = input.nextInt();
}
public void inputMonth () { // Receive input for month.
System.out.print("Enter a month: ");
month = input.nextInt();
}
public void inputYear () { // Receive input for year.
System.out.print("Enter a year: ");
year = input.nextInt();
}
public void displayDate() { // Displays the date in proper form.
System.out.print(year + "/" + month + "/" + day);
}
public int calcDays() { // Calculate days since the initial values.
int days = day-1;
days += ((month-1)*30);
days += ((year -2000) * (12*30));
return days;
}
}