-
Notifications
You must be signed in to change notification settings - Fork 0
/
TimeProgram.java
44 lines (38 loc) · 875 Bytes
/
TimeProgram.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
import java.util.*;
class TimeProgram
{
int hour;
int min;
int sec;
public TimeProgram()
{
this.hour = 0;
this.min = 0;
this.sec = 0;
}
public TimeProgram(int n, int n2, int n3)
{
this.hour = n;
this.min = n2;
this.sec = n3;
}
public TimeProgram(int n)
{
this.hour = n / 3600;
this.min = n / 60;
this.sec = Math.round(((float)n / 60.0f - (float)this.min) * 60.0f);
}
void display()
{
System.out.println(this.hour + ":" + this.min + ":" + this.sec);
}
public static void main(String[] arrstring)
{
TimeProgram t1 = new TimeProgram();
TimeProgram t2 = new TimeProgram(1, 20, 55);
TimeProgram t3 = new TimeProgram(3250);
t1.display();
t2.display();
t3.display();
}
}