-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdder.java
54 lines (45 loc) · 1.51 KB
/
Adder.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
import java.util.* ;
class Adder {
int[] a;
Adder() {
a = new int[2];
}
void readtime(){
Scanner rk = new Scanner(System.in) ;
System.out.println("Enter hour : ");
this.a[0] = rk.nextInt();
System.out.println("Enter minute : ");
this.a[1] = rk.nextInt();
}
void addtime(Adder X, Adder Y) {
int hour1 = X.a[0];
int min1 = X.a[1];
int hour2 = Y.a[0];
int min2 = Y.a[1];
int hourSum = hour1 + hour2;
int minSum = min1 + min2;
this.a[0] = hourSum + (minSum/60);
this.a[1] = minSum%60;
}
void disptime() {
System.out.println("hours = " + this.a[0] + " minutes = " + this.a[1]);
}
public static void main(String[] xc){
Adder obj1 = new Adder();
Adder obj2 = new Adder();
Adder sumObj = new Adder();
obj1.readtime();
obj2.readtime();
sumObj.addtime(obj1, obj2);
sumObj.disptime();
}
}
/*
👋 Hi, I’m @aarushinair - Aarushi Nair (she/her/ella)
👀 I’m a Computer Science Engineering Student
💞️ I’m looking to collaborate on #java, #python, #R, #applicationdevelopment
🌱 #GirlsWhoCode #WomenInTech #WomenInIT #WomenInSTEM #CyberSecurity #QuantumComputing #BlockChain #AI #ML
📫 How to reach me: https://www.linkedin.com/in/aarushinair/
👩🏫 YouTube Channel - Code with Aarushi : https://www.youtube.com/channel/UCKj5T1ELHCmkGKujkpqtl7Q
🙋 Follow me on Twitter: https://twitter.com/aarushinair_
*/