Advertisement
d1i2p3a4k5

9.TIME

Oct 18th, 2014
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. import java.util.*;
  2. import java.lang.*;
  3. class time
  4. {
  5.     int hr,min,sec;
  6.     void accept()
  7.     {
  8.         Scanner t = new Scanner(System.in);
  9.         System.out.println("enter  time ");
  10.         hr = t.nextInt();
  11.         min = t.nextInt();
  12.         sec = t.nextInt();
  13.     }
  14.     void display()
  15.     {
  16.         System.out.println("TIME is "+hr+"/"+min+"/"+sec);
  17.     }
  18.     void add(time a,time b)
  19.     {
  20.         min = (a.sec + b.sec)/60;
  21.         sec = (a.sec + b.sec)%60;
  22.         hr = (min+a.min + b.min)/60;
  23.         min =  min+(a.min + b.min)%60;
  24.         hr = hr+a.hr+b.hr;
  25.     }
  26. }
  27. class test
  28. {
  29.     public static void main(String args[])
  30.     {
  31.         time a = new time();
  32.         a.accept();
  33.         System.out.println("1st  time  is ");
  34.         a.display();
  35.         time b = new time();
  36.         b.accept();
  37.         System.out.println("2nd  time  is ");
  38.         b.display();
  39.         time c = new time();
  40.         System.out.println("addition of 2  time  is ");
  41.         c.add(a,b);
  42.         c.display();
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement