CMSC 104, Section 01, Fall 2016
Problem Solving and Computer Programming

Project 3


Due Date: Thursday, October 13th @ 5:30 PM

Point Value: This project is graded with a 75 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. Each of the programs includes error checking which will be briefly discussed in class.


  1. (15 points) Create a program "campusid_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 cube 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. (30 points) Modify your "campusid_cube.c" program to create a "campusid_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. (30 points) You've got visitors coming over for dinner, and you've decided to make Danish Apple Cake. For four people this requires the following ingredients:
    • 675 g of apples
    • 75 g of butter
    • 150 g of sugar
    • 100 g of breadcrumbs
    • 150 ml of cream
    Write a program "campusid_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 yourself), 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.

When you have finished, submit your campusid_box.c, campusid_cube.c, and campusid_cake.c files using the following commands:

curl -L -F file=@campusid_box.c http://userpages.umbc.edu/~reicht1/classes/cmsc104/fall16/submit.php

curl -L -F file=@campusid_cube.c http://userpages.umbc.edu/~reicht1/classes/cmsc104/fall16/submit.php

curl -L -F file=@campusid_cake.c http://userpages.umbc.edu/~reicht1/classes/cmsc104/fall16/submit.php

Additionally, email your campusid_box.c, campusid_cube.c, and campusid_cake.c files as an attachment to reicht1@umbc.edu using the subject line Project Submission - 3 - Lastname, Firstname, replacing Lastname, Firstname with your name.

Last Modified: October 6th, 2016 8:30 PM