Calculate the angle between hour hand and minute hand
Find out angle between hour hand and minute hand
The minute hand moves 360 degree in 60 minute(or 6 degree in one minute) and hour hand moves 360 degree in 12 hours(or 0.5 degree in 1 minute).
public class HrMinAngle { public static void main(String[] args) { System.out.println(angle(3, 30)); } private static int angle(int h, int m) { // We are going to convert Hr angle to min float hourAngle = (float) 0.5 * h * 60; System.out.println(hourAngle); float minAngle = (float) 6 * m; System.out.println(minAngle); return (int) Math.abs((hourAngle) - (minAngle)); } }
Output : 90