Date assigned: Monday, September 19, 2011
Date due: Wednesday, September 28, 11:00 p.m.
The purpose of this project is to become familiar with the tools needed to complete projects for this course
and to practice input, output, variable types, and mathematical expressions.
Times are sometimes represented in computers as a certain number of seconds or minutes past a given starting
time. Therefore, in programming, it is often necessary to convert hours and minutes to seconds, or vice versa.
Your task in this project will be to write a small C program which prints CMSC106, and also reads a time,
converts it to seconds, and prints two additional facts about it. This is just practice in using the facilities of
C covered so far.
Write a C program which produces several lines of output as described (see the sample execution in
The ﬁrst output line contains only the string CMSC106.
Your program is then to ask the user to type a time, and read the time entered. The time will consist of
two integers, representing hours and minutes respectively, with a single colon appearing between them.
The time entered will be in 24–hour time, so the value 14:15 would signify 15 minutes past 2:00 p.m.,
and 1:15 would signify the time 15 minutes past 1:00 a.m.
On the next line your program is to print the input time, the number of seconds past midnight this time
will occur, and the percentage of how far into the day this time will be. The hours and minutes in the
printed time should be separated by a colon, each printed using two positions. If the number of hours is
a single digit it should be printed with a preceding blank space, and if the number of minutes is a single
digit it should be printed with a preceding zero. For example, the time ﬁve minutes past eight should
be printed as
to indicate a printed space).
The percentage ﬁgure should be printed as a number between zero and 100, equal to the nearest whole
number not greater than the percentage value. For example, since a day is 24 hours, at time 12:00 it
will be 50% over, and 75% over at 18:00. Also see the example below. The percentage ﬁgure must be
immediately followed by a percent sign (%), not separated from the number by any space.
The next line must contain the number of seconds between the input time and the end of the day (at
The last line tells the current time by a diﬀerent deﬁnition. You are working with the beings on another
planet that has observed how long an earth day is. (This is one revolution of the earth - so this is the
same as deﬁned by earthlings and beings on this other planet.) But they divide the day into bleeps,
blips and seconds. Seconds have the exact same length of time as our seconds. There are 200 seconds
in a blip. There are 54 blips in a bleep. There are 8 bleeps in a day. In their format they write the
where the bleeps are always written as a one digit value, the blips are