-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdd_Time.java
More file actions
35 lines (35 loc) · 754 Bytes
/
Add_Time.java
File metadata and controls
35 lines (35 loc) · 754 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
import java.util.Scanner;
class Add_Time
{
public static void main(String args[])
{
Add_Time t1=new Add_Time();
Add_Time t2=new Add_Time();
t1.input();
t2.input();
t1.show();
t2.show();
Add_Time t3=new Add_Time();
t3.add(t1,t2);
t3.show();
}
int hour,min;
void input()
{
Scanner sc=new Scanner(System.in);
System.out.println("enter the time");
hour=sc.nextInt();
min=sc.nextInt();
}
void show()
{
System.out.println("The time is "+hour+":"+min);
}
void add(Add_Time t1,Add_Time t2)
{
hour=t1.hour+t2.hour;
min=t1.min+t2.min;
hour=hour+min/60;
min=min%60;
}
}