Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.lang.*;
- class time
- {
- int hr,min,sec;
- void accept()
- {
- Scanner t = new Scanner(System.in);
- System.out.println("enter time ");
- hr = t.nextInt();
- min = t.nextInt();
- sec = t.nextInt();
- }
- void display()
- {
- System.out.println("TIME is "+hr+"/"+min+"/"+sec);
- }
- void add(time a,time b)
- {
- min = (a.sec + b.sec)/60;
- sec = (a.sec + b.sec)%60;
- hr = (min+a.min + b.min)/60;
- min = min+(a.min + b.min)%60;
- hr = hr+a.hr+b.hr;
- }
- }
- class test
- {
- public static void main(String args[])
- {
- time a = new time();
- a.accept();
- System.out.println("1st time is ");
- a.display();
- time b = new time();
- b.accept();
- System.out.println("2nd time is ");
- b.display();
- time c = new time();
- System.out.println("addition of 2 time is ");
- c.add(a,b);
- c.display();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement