Homework #3

Due: Sept. 24, 2004 (F)

Your assignment is to write a program to tally weekly sales for a mail-order house. The mail order house sells five different products whose retail prices are shown in the below table.

Product Number Retail Price
1 $3.44
2 $5.02
3 $2.14
4 $6.30
5 $7.11

The program should read a series of pairs of numbers representing a product number and quantity sold. You can use a sentinel-value of -999 for the product number to stop input.

The program should calculate and display the total retail sales for each products individually and the total overall sales.

Again, use the Linux system to edit, compile, execute, and debug your programs.

The steps you need to follow for this lab are similar to the last lab.

  1. use some editor (nano, pico, vi, emacs, etc.) under Linux to type your program into a file named "pgm3.c". For example, use the command "namo pgm3.c"
  2. compile the program using the GNU C compiler by typing: gcc -o pgm3 pgm3.c

    (which puts the executable programming in the file called "pgm3")

  3. If you have syntax errors, the compiler will tell you a line number and some poorly worded indication of the cause for each error. While you still have errors, go back to step (1) to edit your program and then recompile. When you have no syntax errors, go on to step (4).
  4. execute your program sending the output to the screen by typing:

    "./pgm3" where the "./" indicates the pgm3 in the current directory.

  5. If your program does not give the expected results, think about your logic before going back to step (1) to fix your program. When thinking about your logic, I would recommend playing computer and hand tracking each statement like the computer would. Hopefully, this will expose your semantic errors.

To submit your assignment, click on the link at the bottom of the homework page for the course: http://www.cs.uni.edu/~fienup/cs036f04/homework/index.htm

You will need to

  1. log on to the submission system using your CNS account information
  2. select the "810:036, C++ Fienup" course
  3. select the radio button corresponding to lab being submitted
  4. enter the name of the file you wish to submit which needs to be accessable on the computer from which you are submitting