You are to write a program that calculates heating degree days. These numbers are used by the utility companies to determine approximate usage of heating oil, gas, and electricity during months that require heating. Your program is to be interactive, repeatedly prompting the user for a "City name," a "Low temperature,", and a "High temperature." It should then calculate the number of degree days for that city and display the city's name and the number of heating degree days it has accumulated.
To calculate the number of heating degree days for a day, compute the average temperature for the day and subtract this average from 65. The difference is the number of heating degree days for that day in the city where the temperature readings are made. If the average temperature is 65o or higher, the number of heating degree days is zero. Note: averages are expected to be truncated, not rounded, results.
As your program calculates and displays the heating degree days for each city entered, it should keep track of the total number of degree days accumulated by all cities entered. In addition, your program should take note of the lowest temperature and highest temperatures seen from any city entered.
To end the program, the user will enter nothing (just press Enter) at the "City name" prompt. Your program should then display the aggregate information that it has been gathering, with appropriate labels: total heating degree days, lowest temperature, and highest temperature.
You are expected to use Irvine's library procedures for reading and writing integers and strings throughout this program.
Hand in an assembler-generated listing of your program. Also, hand in a floppy disk with your source program on it. Your program must be in a file named
yourinitials-p3.asm
For example, if I were handing in this program, my file would be
JLW-P3.ASM because my initials are JLW.
Here is a sample of what your output might look like. User input
is shown in bold to distinguish it from what the program generates.
City name: Indiana Low temperature: 28 High temperature: 44 Indiana had 29 heating degree days. City name: Goose Bay Low temperature: -17 High temperature: -4 Goose Bay had 76 heating degree days. City name: Hilo Low temperature: 72 High temperature: 84 Hilo had 0 heating degree days. City name: Johnstown Low temperature: 22 High temperature: 37 Johnstown had 36 heating degree days. City name: Total heating degree days for all: 141 Lowest temperature: -17 Highest temperature: 84