Clock Angle Problem: Given time in HH:MM format, calculate the smallest angle between Hour hand and Minute hand.
Few examples shown in the table
Time | 1:00 | 2:30 | 7:00 | 10:30 | 11:20 | 3:40 | 5:15 | 8:45 |
Angle | 30° | 105° | 150° | 135° | 140° | 130° | 67½° | 7½° |
In the above picture, small angle between hour and minute hand is 30° when the time is 1'o clock.
Explanation:
- In 12 hours, hour hand rotates 360° , then in 1 hour it rotates 360°/12 = 30°
12 hours ---> 360°
1 hour ---> 360°/12 = 30°
- In 60 minutes, minute hand rotates 360° , then in 1 minute it rotates 360°/60 = 6°
60 minutes ---> 360°
1 minute ---> 360°/60 = 6°
- Difference between these two angles is the angle between Hour hand & Minute hand.
- If the angle is greater than 180° , then subtract it from 360° as we need small angle.
Java program to find angle between Hour and Minute hands :
Output :
Enter Time: 1:00
Small Angle b/w Hour and Min Hands : 30.0
Enter Time: 2:30
Small Angle b/w Hour and Min Hands : 105.0
No comments:
Post a Comment