EE150 - Fall 1996

Programming Assignment #2
Solution


------
Part 1:
This solution involved typing in the price2.c program in the text and then modifying it to reflect that we are using it for the specific task of keeping track of textbook purchases. This meant changing the various strings used in the output, as well as changing the #define's that described how many texts were purchased, the price, and the discount and tax rates.

Our solution is in textbooks.c.

Part 2:
This part involved extending the program in the previous part to produce a table of output. The key here is to use a counting a loop that runs from 1 to 18. Each time through the loop, you need to have the calculation part of the previous program, except that you need to modify it to use the loop counter as the number of texts (rather than a constant). You also have to add the headings and worry about how to line things up in columns, and add a new tax.

Our solution is textbooks2.c.

Part 3:
This program fits the same general pattern as the price-computing program: some constant definitions, some variable declarations, a set of calculations, and a set of printf's to produce the output.

Our solution is trip.c.

Part 4:
This program is actually mostly a simple input-reading loop wrapped around the calculations and output-generating statements of the solutions to the previous part.

Our solution is trip2.c.

In Class Bonus:
This was simple - if it wasn't for you, it's time to do some more thinking.

A couple of solutions are given in simple.c.