CMSC 104, Section 01, Fall 2016
Problem Solving and Computer Programming
Thursday, October 13th @ 5:30 PM
This project is graded with a 75 point max score.
To become more familiar with:
- C program creation, compilation, and execution
- Algorithm/solution implementation
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.
- (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.
- (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.
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:
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.
- 675 g of apples
- 75 g of butter
- 150 g of sugar
- 100 g of breadcrumbs
- 150 ml of cream
When you have finished, submit your campusid_box.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
, and campusid_cake.c
files as an attachment to email@example.com
using the subject line Project Submission - 3 - Lastname, Firstname
, replacing Lastname, Firstname
with your name.
Last Modified: October 6th, 2016 8:30 PM