UMBC CS 104
UMBC CMSC 104 * CSEE | 104 | current 104

Project 3 - More Algorithms and C Programming

CMSC 104, Fall 2002

Due Date: 5:30 pm, Tuesday, 10/8.

Point Value:

This project is graded with a 20 point max score.

Objectives:

To become more familiar with:


This assignment consists of three programming problems based on work that was done during class. Each of the programs should include a descriptive header comment, well-structured source code, and meaningful comments. To submit your project, email the TA at pliu2@cs.umbc.edu with three attachments, one for each program. Each of the programs includes error checking which will be briefly discussed in class on 10/1.


  1. (6 points) Create a program "cube.c" for calculating the volume and surface area of a cube based on the pseudocode worked on in class. The program should prompt the user for the length of the sides of the compute and print to standard output both the volume and the surface area of the cube. Use preprocessor directives where appropriate (hint: a cube always has 6 sides). Error checking should be performed to ensure that the user does not input a negative length. If the user does input a negative length, an appropriate error message should be displayed and the calculation should not be completed. NOTE: the user should be able to input a "real" value for the length.


  2. (6 points) Modify your "cube.c" program to create a "box.c" program that calculates the volume and surface area of box. The user should be prompted to input the box's length, width, and height. The code should ensure that the user does not input negative values for any of the inputs. If any of the input values is negative, an appropriate error message should be displayed and the calculations should not be completed. NOTE: the user should be able to input "real" values for the length, width, and height.


  3. (8 points) When visitors come for dinner, my wife and I always make Danish Apple Cake. For four people this requires the following ingredients: Write a program "cake.c" which inputs the number of people coming to dinner, and then prints the amount of each ingredient required (the ingredients always scale linearly). Your program should use preprocessor directives (hint: for the standard ingredient list) and should ensure that the user always inputs a number of visitors that is greater than zero. The printed results should include the total number of people (including my wife and I), and the ingredients in a list that looks similar to the list above (with two significant digits after the decimal point). The number of visitors will always be an integer.


IMPORTANT: Any questions about this assignment
will be addressed in the lab on Thursday, 10/3!



Last Modified: Thursday, 03-Oct-2002 02:29:25 PM EDT