UMBC CMSC 104 Spring 2001 CSEE | 104 | current 104

UMBC CMSC 104 -- Spring 2001

Homework 7

Objectives

Assignment

Your program will prompt the user to enter the width, height, and depth of a box. It will allow the user to enter only positive integers as the dimensions of the box by error checking each dimension as it is entered. The program should make the user keep entering a value until he/she enters a positive integer. You MAY assume that the user will enter only integers (i.e., no real numbers or characters will be entered). See the Sample Program Run below.

Once the user has entered valid values for width, height, and depth, the program will ask the user for a character with which to draw the different surfaces of the box.

Next, the program will present the user with a menu of options. The options are shown in the Sample Program Run below.

The functions you will write, in addition to the main function, are:

Each function corresponds to a menu option. The menu should continue to display until the user enters a Q for quit. You should only allow the user to enter UPPERCASE menu options.

Sample Program Run

Here is a sample run of the program.

Enter the width: 0 Please enter a positive integer: -2 Please enter a positive integer: 5 Enter the height: -1 Please enter a positive integer: 7 Enter the depth: 0 Please enter a positive integer: 4 Enter a character to be used to draw: # Menu A -- Calculate the Surface Area of the Box V -- Calculate the Volume of the Box F -- Display the Front/Back of the Box T -- Display the Top/Bottom of the Box S -- Display the Side of the Box Q -- Quit Selection: B B is an invalid menu option. Menu A -- Calculate the Surface Area of the Box V -- Calculate the Volume of the Box F -- Display the Front/Back of the Box T -- Display the Top/Bottom of the Box S -- Display the Side of the Box Q -- Quit Selection: a a is an invalid menu option. Menu A -- Calculate the Surface Area of the Box V -- Calculate the Volume of the Box F -- Display the Front/Back of the Box T -- Display the Top/Bottom of the Box S -- Display the Side of the Box Q -- Quit Selection: A The surface area is: 166 Menu A -- Calculate the Surface Area of the Box V -- Calculate the Volume of the Box F -- Display the Front/Back of the Box T -- Display the Top/Bottom of the Box S -- Display the Side of the Box Q -- Quit Selection: V The volume is: 140 Menu A -- Calculate the Surface Area of the Box V -- Calculate the Volume of the Box F -- Display the Front/Back of the Box T -- Display the Top/Bottom of the Box S -- Display the Side of the Box Q -- Quit Selection: F ##### ##### ##### ##### ##### ##### ##### Menu A -- Calculate the Surface Area of the Box V -- Calculate the Volume of the Box F -- Display the Front/Back of the Box T -- Display the Top/Bottom of the Box S -- Display the Side of the Box Q -- Quit Selection: T ##### ##### ##### ##### Menu A -- Calculate the Surface Area of the Box V -- Calculate the Volume of the Box F -- Display the Front/Back of the Box T -- Display the Top/Bottom of the Box S -- Display the Side of the Box Q -- Quit Selection: S #### #### #### #### #### #### #### Menu A -- Calculate the Surface Area of the Box V -- Calculate the Volume of the Box F -- Display the Front/Back of the Box T -- Display the Top/Bottom of the Box S -- Display the Side of the Box Q -- Quit Selection: Q

Your program's output should follow this EXACT formatting.

Coding Standards and Indentation

Make sure that you follow the "C Coding Standards" and "Indentation Styles". Your program will be graded not only on whether or not it produces the correct results, but also on whether or not you follow these standards and styles.

Algorithm

Include the algorithm for you program within the header of your program. You will not receive full credit if you don't include your algorithm.



6:42 PM 1/23/01