An analog clock is a device that shows the time of day by moving two pointers, an hour hand and a minute hand, through a circle. The hour hand moves uniformly clockwise through the circle once every twelve hours. The minute hand moves uniformly clockwise through the circle once every hour. The numbers 1 through 12 are arranged around the circumference of the circle such that 12 is at the top, and each number k is 20° counterclockwise from the k+1. At 12:00 midnight, both hands point directly to the 12. At 12:30 AM, the hour hand points midway between the 12 and the 1, and the minute hand points directly at the 6. At 1:00 AM, the hour hand points directly to the 1 and the minute hand points directly to the 12, and so forth.
Write a program to determine the angle between the hands of the clock at a specified time. Use any convenient angular measure.
At what times of day, to the nearest second, do the hands of the clock point in exactly opposite directions?
At what times of day, to the nearest second, do the hands of the clock make a right angle?
A second hand is a third pointer that moves uniformly clockwise through the circle once every minute. At 12:00 midnight, all three hands point directly to the 12. Determine how many times per day all three hands of the clock are collinear (either all three pointing exactly in the same direction, or one pointing exactly opposite the other two). Determine how many times per day the hands form one or two right angles (either two pointing exactly in the same direction with the third at a right angle, or two pointing exactly in opposite directions with the third at a right angle).
Copyright © 2002 Brian Hetrick
Page last updated 3 March 2002.
Building Blocks I
Control Flow II
A First Program
Data Structures I
Building Blocks II
Data Structures II