The objectives of this lab are to give you practice at using functions and while loops. In addition, you will be expected to begin thinking in terms of the algorithms for your programs before coding. For this lab, we ask you to turn in a text file called algorithms containing the algorithms for the last two problems in addition to the source code. We will also begin looking for proper source code formatting and documentation (comments) in your files.
You should begin by creating a new directory called Lab4 in your EE160/Labs directory (which you have created in previous labs). All of the program files you write for this lab should be in this Lab4 directory.
float tocelsius(float fahrenheit);
/* Given: a temperature reading in degrees Fahrenheit
Returns: the temperature in degrees Celsius
*/
Modify the driver, main(), to prompt the user to enter a temperature in Fahrenheit, convert the value using the function and print the result. The driver should loop asking the user for input until a special data value is entered. Since 0 is a valid Fahrenheit temperature, we need something else. Physics tells us that no temperature can be lower than absolute zero (-273 degrees C, or -459 degrees F), let's use -500 as the special data value to terminate Fahrenheit input. Your file will be called temperature.c.
int temptable(float start, float stop);
/* Given: starting and ending temperatures in degrees Fahrenheit
The function prints a table of conversions from degrees
Fahrenheit to degrees Celsius from start to at most stop
in five degree F increments, one conversion per line.
Returns: the number of table lines printed.
*/
HOWEVER; before you write ANY code for this program, you should begin by writing the algorithms for the function temptable() and the driver main() IN WORDS. You should write these algorithms in a text file called algorithms, which you WILL turn in for this lab (worth 2 points). You can then use the steps in your algorithm as comments in your source code file.
acc_amount = acc_amount + acc_amount * annual_interest
Use a function that returns the accumulated value given the amount, interest, and years. The prototype is:
float calc_acc_amt(float acc_amount, float annual_interest, int years);
Use the "grade" command to turn in the algorithms file and the five programs (countup.c, countdown.c, temperature.c, temptbl.c, and account.c). Your command will look like the following.
If you are in Section 001 use:
grade -lab4s1,ee160 algorithms countup.c countdown.c temperature.c temptbl.c account.c
If you are in Section 002 use:
grade -lab4s2,ee160 algorithms countup.c countdown.c temperature.c temptbl.c account.c
If you are in Section 003 use:
grade -lab4s3,ee160 algorithms countup.c countdown.c temperature.c temptbl.c account.c
If you are in Section 004 use:
grade -lab4s4,ee160 algorithms countup.c countdown.c temperature.c temptbl.c account.c
You should verify that you turned in things successfully, which you can do with the command (which simply leaves the file names off from the previous command).
grade -lab4s1,ee160
OR
grade -lab4s2,ee160
OR
grade -lab4s3,ee160
NOTE: after the files are prepared for grading, you will no longer be able to see your file listing using the above command.