APPLIED PROGRAMMING (APR520S) ASSIGNMENT 1

Problem Solving Tools Total Marks: 50 Marks Due: Friday 22 August 2014

Suppose we want to construct a C/C++ program that can be used to calculate the area or the volume for a range of 2-D and 3-D shapes respectively. Consider only the following shapes.
(a) 2-dimensional shapes: triangle, square, rectangle, circle, and trapezium

(b) 3-dimensional shapes: cuboid, cylinder, cone, and sphere

Suppose that we want our program to firstly ask the user whether to calculate the area (2-D) or volume (3-D), then secondly ask for the type of the shape, then thirdly ask for inputs of all required dimensions, then fourthly calculate the required area or volume, and then finally display the required result to the user.

Required:

1. Construct a flowchart for this C/C++ program. [15]
2. Develop a pseudocode for this C/C++ program. [15]
3. Construct a hierarchy (structure) chart for this C/C++ program. [10]
4. Construct an IPO chart for this C/C++ program. [10]

1 answer

Technically you do not need to ask for a 2D or 3D calculation because there is no overlap of the shape names.

You will need a string of if-else-elseif-endif statements, or more conveniently a switch statement. Use the "default:" option in case the user feeds a wrong shape.

Evidently the input and calculations are all different for all cases, but the output can be done in two cases, 2D or 3D (which can be determined according to the shape).

Post your proposition (pseudocode) and comments will be offered.