COSC 1435 Lab 5
Purpose:
This lab focuses on writing a simple C++ program.
Due:
Before class on March 4,
2013
Video
Introduction: The video introduction for this lab
is in Blackboard. I develop the pseudocode for the lab in this video.
Requirements:
Do the following:
1. Develop pseudocode
and write a program that finds the area of a circle and a triangle, and the
volume of a cube. Do the following:
-
Have the user
find the perimeter and area of a rectangle as follows:
-
Ask the
user to input the height and width of the rectangle.
-
Calculate
the area of the rectangle by multiplying the width by the height.
Output this value.
-
Calculate
the perimeter of the rectangle by multiplying (2 * width) + (2 * height).
Output this value.
-
Have the user
find the area of a circle as follows:
-
Ask the
user to input the radius of the circle.
-
Calculate
the area of the circle using the following formula: PI * r * r, where
r is the radius of the circle. The approximate value of PI is 3.1416.
- Output the area of the circle.
-
Have the user
find the area of a triangle as follows:
-
Ask the
user to input the base and the height of the triangle.
-
Calculate
the area of the triangle using the following formula: 1/2 * b* h, where
b is the length of the base of the triangle and h is the height of the
triangle.
- Output the area of the triangle.
-
All variables
should be double values to ensure that floating point information is
properly handled.
2. Format your output
so that the user of your program understands the values that were input and
what was output for each calculation. Your program should have a user-friendly
interface.
3. Make sure your program is properly
documented and good programming standards are followed. For this program you
must have a program identification/summary section and comments that explain
each of the calculations.
4. Try your program with a variety
of input values, to determine it works properly. Some of the values you should
try include positive, negative, integer, floating point numbers, and zero. You
should try these combinations of numbers in both the first and second number.
Describe what happens when you input zero and negative numbers in your lab report.
Are there any other combinations of numbers that give inaccurate results, if
so fix your program so that it works properly or describe what is happening
and why in your program documentation.
5. This lab requires a lab report/documentation
package. All of these items are not typically in the same file (source code
and sample output should definitely be in their own files), but the main lab
report file must reference each item by name. Here is a sample
lab report. The main lab report must either be a text file (with a .txt
extension) or a Microsoft Word file (with a .doc extension). The lab report
must includes the following or references (the file name that was attached to
the mail) to the following information:
-
-
-
-
-
Program output, with sample data
-
How was this program tested
-
What problems/successes did you have with this program?
-
An estimate of how much time you spent working on this
lab
Program
Submission. You will be submitting this lab via
Blackboard. Prepare the following:
-
Your program source
code. This file should be called lab05***.cpp, where the *** is replaced
with your initials.
-
A copy of your
program output saved as a file. This file should be called lab05***.txt,
where the *** is replaced with your initials. The .txt signifies that this
is an ASCII text file.
-
A lab report as
described above. The lab report may be in a Microsoft Word document, with
a .doc suffix or an ASCII text file with a .txt suffix. Make sure it contains
all of the required items. This file should be called either lab05***doc.txt
for a text file or lab05***doc.doc for a Microsoft Word file, where the
*** is replaced with your initials.
Grading
Criteria: 100 points available for this lab. Following
is the grading criteria for this lab: