CS 1320 (Principles of Algorithm Design I):
Homework #1

Assigned:
January 21, 2000.
Due:
January 28, 2000, at start of class.
Credit:
20 points (10 points per problem).

Instructions

Write a C++ program to solve each of the problems below. Your code should begin with comments that describe what the program is supposed to do, in terms of its inputs and outputs. See the sample programs for examples.

Problems

Temperature conversion

Write a program to convert a Fahrenheit temperature to Celsius. The rule for converting Fahrenheit temperature F to Celsius temperature C is: C = (5/9)(F - 32) . The program should ask the user for the Fahrenheit temperature and print the equivalent Celsius temperature. You can use integers for this problem, since we have not yet discussed floating-point numbers.

Seconds to years, etc. conversion

Write a program that prompts the user for a number of seconds S (S should be a non-negative integer) and prints S in a more normal notation -- years, days, hours, minutes, and seconds. You may ignore leap years and seconds. For example, 100 seconds is 1 minute and 40 seconds. (You may be interested to run this program using successive powers of 10 as input and see how long it takes before seconds start to add up to years.)

What to turn in

Submit your source code as described in the guidelines for programming assignments. For this assignment: