View Code of Problem 56

import java.util.Scanner;

public class Main
{
  public static void main(String[] args)
  {
    Scanner scan=new Scanner(System.in);
    int h=scan.nextInt();
    int m=scan.nextInt();
    int s=scan.nextInt();
    int hh=scan.nextInt();
    int mm=scan.nextInt();
    int ss=scan.nextInt();
    
    int t1=h*3600+m*60+s;
    int t2=hh*3600+mm*60+ss;
    int t=abs(t1-t2);
    
    int h1=t/3600;
    int m1=t/60;
    int s1=t%60;
    
    System.out.println(String.format("%d:%2d:%2d",h1,m1,s1));
    
  }
}
/*
Main.java:17: error: cannot find symbol
    int t=abs(t1-t2);
          ^
  symbol:   method abs(int)
  location: class Main
1 error
*/

Double click to view unformatted code.


Back to problem 56