PROGRAM ASSIGNMENT #2

Dr. Harris
DUE: 1:00 pm, Friday, February 9, 2001
VALUE: 40 pts.

Write a program which will accept the value of a certain number of seconds. Your program will output this number of seconds as an equivalent number of years, weeks, days, hours, minutes and seconds. Your output must look very much like the following examples:

Enter the number of seconds you wish to convert: 1000000 

=================================================================
Years       Weeks        Days       Hours     Minutes     Seconds
=================================================================
  0           1           4          13          46          40
=================================================================
Program complete.
Programmed by <your name here>
171 - <your section here>
<Due date here>  Value = 40 pts.
=================================================================

Enter the number of seconds you wish to convert: 700000000

=================================================================
Years       Weeks        Days       Hours     Minutes     Seconds
=================================================================
 22          10           1          20          26          40
=================================================================
Program complete.
Programmed by <your name here>
171 - <your section here>
<Due date here>  Value = 40 pts.
=================================================================
Use only integer storage and arithmetic in your program. (Since values above 30000 are somewhat more interesting, be sure to use type LONGINT for critical storage locations.) Declare the individual conversion values in the Const section. Turn in: a program listing of your program and a printed copy of a computer run which answers the question: how old will you be (in years, weeks, etc.) when you have lived two billion seconds? Model your output on those examples shown above. Turn in your program on a virus-free disk. Your program file must use the name PRG2_S01.PAS. Hard corded constants in your program will cause significant point deductions! You can define conversion constants as follows:

Const
  Seconds_per_minute = 60;
  Seconds_per_hour = 60 * 60;
  Seconds_per_day = 60 * 60 * 24;
etc.

Your conversion algorithm should assume that a day consists of 24 hours and that a year consists of 365 days rather than 52 weeks. (Note that 52 * 7 is equal to 364!).

Use a prolog in your program similar in layout to the one used in Program 1. Your prolog should point out any inherent limitations in your program. Programs without prologs and/or poor documentation will be returned to be redone.

Some major causes of redos on this program:

  1. Some required materials and/or printouts not turned in.
  2. Poor or missing prolog and/or documentation in program (see the Documentation section of the Program Criteria).
  3. Using embedded hard-coded constants in computational expressions.
  4. Some directions not followed under the Miscellaneous section of the Program Criteria
  5. Some portions of required output missing.
  6. Your program produces incorrect output when I run it against test data.

Carefully read and follow the Policies on Writing and Submitting Programs section of the Program Criteria, also.


Return to
CS-171
Home Page
    Return to
UW-W
Home Page
   
This page last updated
1 February 2001