Sunday, March 14, 2010

The Fourth Annual Computer Competition (Part 4 of 4)

(Introduction and Part 1Part 2, Part 3, Part 4)

The fourth question, Question #5.

Question #5: Senior Division

Compact Disks (CD's) offer the latest advantages in digital sound. Each disk is capable of prividing almost 75 minutes of music. You are currently creating a catalog of your disks (on your computer, naturally) that will list the total time (in hours:minutes:seconds) fro each CD. Unfortunately, while most disk labels list the time for each selection, many do not list the total time for the complete album (although must CD players display this information when you first insert the disk prior to playing it.)

Write a program that (a) asks for the number of selections on the disk (b) asks for the time of each selection in the exact format [minutes:seconds] -- including the colon and (c) outputs the total time of the CD in the format [HH:MM:SS] (Hours:Minutes:Seconds). NOTE: 00:63:29 would be wrong. 01:03:29 would be correct,etc,

IMPORTANT INFORMATION: You may assume that no selection is over 59 minutes and 59 seconds long [59:59] and that the judge will input the data with no spaces between the numbers and the colon. However, the judge may or may not input the minute information with a leading zero. For example, your program should be able to handle 2 minutes and 12 seconds input by the judge either in the form 2:12 or 02:12. Finally your output must be in the format HH:MM:SS or it will not be judged correct. That is, there must be two digits for each position (hours, minutes and seconds) and the output must not have any spaces between the digits and the colons. Some example include (see the SAMPLE RUNS for others):

Correct:Incorrect:Correct:Incorrect:
00:07:3300:7:3302:13:1202 : 13 : 12

SAMPLE RUNS
RUN

HOW MANY SELECTIONS ON THE DISK? 5

TIME FOR SELECTION # 1 (MINUTES:SECONDS)? 29:45
TIME FOR SELECTION # 2 (MINUTES:SECONDS)? 13:32
TIME FOR SELECTION # 3 (MINUTES:SECONDS)? 9:12
TIME FOR SELECTION # 4 (MINUTES:SECONDS)? 02:12
TIME FOR SELECTION # 5 (MINUTES:SECONDS)? 12:52

TOTAL TIME OF DISK = 01:07:33

RUN

HOW MANY SELECTIONS ON THE DISK? 3

TIME FOR SELECTION # 1 (MINUTES:SECONDS)? 4:59
TIME FOR SELECTION # 2 (MINUTES:SECONDS)? 26:26
TIME FOR SELECTION # 3 (MINUTES:SECONDS)? 01:09

TOTAL TIME OF DISK = 00:32:34




No comments: