finalreport3 - University of Cincinnati Department of...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
University of Cincinnati Department of Computer Science CS 121-002 Computer Science 1 Laboratory 3 Final Report Benjamin Jones 24 January 2008 1. Introduction The purpose of this laboratory is to learn how to utilize input/output statements, expressions, assignment statements, integer variables, constants, and IF statements in a practical example involving calculating the area of several geometric figures. More specifically, the program must calculate the area of a circle, square, or isosceles triangle, depending on what the user wants. The program will be reprogrammed several times using different standards. 2. The Program(s) // *********************************************************************** // File: lab3a.cpp // // Area of a user selected figure - User selects a geometric figure, the // user inputs some information based on // the figure chosen, and the program outputs // the area of the chosen figure. // // // Author: Benjamin Jones // Created: 24 January 2008 // Updated: Original // // Assignment: 2.16 // Compiler: MinGW32 G++ 3.4.2 (GNU) // // Inputs: Choice of geometric figure, "1" for circle, "2" for square, and "3" // for isosceles triangle with base equal to height. The use must also // input the diameter of the circle for a cricle, the length of the // square for a square, or the base of the triangle for the triangle. // Outputs: Display message, "<object> is of area=<area>" where object is either // "circle", "square", or "triangle" and area is the area in floating // point (expressed as variable type "double" // ********************************************************************* // // Design: // // 1. Get input from user // a) Read input // b) Determine whether the user selected triangle, circle, or square // 1. Get input from user depending on each figure // a) If circle get diameter
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
// 1. Read input // b) If square get length // 2. Read input // c) If triangle get height // 3. Read input // // 2. Calculate area of the selected geometric figure // a) If circle, calculate area of a circle // b) If square, calculate area of a square // c) If triangle, calculate area of a isosceles triangle where base // equals height // // 3. Display message "<object> area = <area> where <object> is a circle, // square, or triangle, and <area> is a floating point number, and // message is based upon object selection. // a) If circle, <object> = circle // b) If square, <object> = square // c) If triangle, <object> = triangle // // *********************************************************************** #include <iostream> using namespace std; const int OK = 0; const double PI = 3.14; int main() { int menuChoice = 0; double diameterOfCircle = 0.0; double lengthOfSquare = 0.0; double heightOfTriangle = 0.0; double areaOfObject = 0.0; // 1. Get input from user cout << "Please select the geometric figure you want to find the area for" << endl; cout << "****************************************************************" << endl; cout << "1) Circle" << endl;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This lab report was uploaded on 04/18/2008 for the course ECEE 120 taught by Professor Carter during the Winter '08 term at University of Cincinnati.

Page1 / 13

finalreport3 - University of Cincinnati Department of...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online