First, solve the problem. Then, write the code. ” - John Johnson

It's not at all important to get it right the first time. It's vitally important to get it right the last time. ” - Andrew Hunt and David Thomas

Wednesday, July 16, 2014

Clock Hands.

Author : Jisan
Programming language : Java
Difficulty : Easy
Status: Accepted
Problem number : UVA-579
http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=520

Code:

import java.util.*;
public class Uva_579 {

   public static void main(String[] args) {
       Scanner s = new Scanner(System.in);
           while(s.hasNext()){
          String tomato=s.nextLine();
          StringTokenizer jis=new StringTokenizer(tomato,":");
          double hour=Integer.parseInt(jis.nextToken());
          double mins=Integer.parseInt(jis.nextToken());
       
        if(hour==0 && mins==0){
        break;
        }
        double jisan=Math.abs(.5*(60*hour-11*mins));
        if(jisan>180){
        jisan=360-jisan;
        }
        System.out.printf("%.3f\n", jisan);
           }
         
   }
}

No comments:

Post a Comment