Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Rectangle Area
- // Jennifer Burgess and Julie Miller
- // CSCI 193
- // Program #24
- // 7/24/14
- /*The Program will ask the user to enter the width and length of a rectangle, and then display the rectangle's
- area by calling functions*/
- #include "stdafx.h"
- #include <iostream>
- #include <iomanip>
- using namespace std;
- // Write the prototypes for the getLength,
- // getWidth, getArea, and displayData
- // functions here.
- double getLength();
- double getWidth();
- double getArea(double, double);
- double displayData(double, double, double);
- int main()
- {
- double length; // The rectangle's length
- double width; // The rectangle's width
- double area; // Multiplying Length * Width
- double num; // The rectangle's area
- cout << "Hello. " << endl;
- // Calling variables.
- // Get the rectangle's length.
- length = getLength();
- // Get the rectangle's width.
- width = getWidth();
- // Get the rectangle's area.
- area = getArea(length, width);
- // Display the rectangle's data.
- displayData(length, width, area);
- return 0;
- }
- //***************************************************
- // You must write the getLength, getWidth, getArea, *
- // and displayData functions. *
- //***************************************************
- double getLength() //Function Header
- {
- double length;
- cout << "Enter the length of the triangle and press enter." << endl;
- cin >> length;
- return length;
- }
- double getWidth() //Function Header
- {
- double width;
- cout << "Enter the width of the triangle and press enter." << endl;
- cin >> width;
- return width;
- }
- double getArea(double length, double width) //Function Header
- {
- return length * width;
- }
- double displayData(double length, double width, double area) //Function Header
- {
- cout << "The length of the triangle is " << setw(3) << length << endl;
- cout << "The width of the triangle is " << setw(4) << width << endl;
- cout << "The area of the triangle is " << setw(5) << area << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement