Hands On C++: Project 1


The Projects

Your instructor will assign you one of the problems below. To solve your problem, write a program that reads the necessary information to compute and output the indicated values, as efficiently as possible. Following the pattern in the lab exercise, first, design using OCD; then code your design in C++ using stepwise translation; finally, test your program thoroughly.

Project #1.1: Modify the program from the lab exercise to also print out the area of the triangle:
double area = 0.5 * leg1 * leg2;
cout << "The area is " << area << endl;

Note: In the following formulas, π is the symbol for "pi" on this browser.

Project 1.2. Write a program to input the radius of a circle and then compute and output its circumference and area. The formulas for these quantities are as follows:

circumference = 2 π r
area = π r2

where r is the radius of the circle.

Project 1.3. Write a program to input the radius of the circular base and the height of a right circular cylinder and then compute and output its surface area and volume. The formulas for these quantities are as follows:

surface area = 2 π rh
volume = π r2h

where r is the radius of the circular bases of the cylinder and h is its height.

Project 1.4. Write a program to input the lengths of the two axes of an ellipse and the compute and output its circumference and area. The formulas for these quantities are as follows:

        circumference = 2π x the square root of ( ( (a/2)2 + (b/2)2 ) / 2 )
        area = π ab

where a and b are the lengths of the major and minor axes of the ellipse.

Project 1.5. Write a program to to input the radius of a sphere and then compute and output its the surface area and volume. The formulas for these quantities are as follows:

surface area = 4π r2
volume = (4/3)π r3

where r is the radius of the sphere.

Turn In

Turn the following things:

  1. This grade sheet.
  2. You OCD design.
  3. Your source program.
  4. The output from an execution of your program.


Lab Home Page | Lab Exercise
© 2003 by Prentice Hall. All rights reserved.
Report all errors to Jeremy D. Frens.