UVA – 579 – ClockHands

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        while (!s.equals("0:00")) {

            String[] cl = s.split(":");

            double h = Integer.parseInt(cl[0]), min = 
                       Integer.parseInt(cl[1]);

            h = h*30.0 + (min/60.0)*30.0;
            min = min*(360.0/60.0);

            double angle = Math.abs(h - min) > 180 ? 360.0 -
                           Math.abs(h - min) : Math.abs(h - 
                           min);

            System.out.printf("%.3f\n", angle);
            s = in.nextLine();
        }
    }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: