Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Christian Ballard
- COSC 1336 - 001
- PA #1 - Rectangle Area
- January 13, 2015
- */
- #include <iostream>
- using namespace std;
- // Prototypes for getLength, getWidth, getArea, and display Data functions.
- double getLength();
- double getWidth();
- double getArea(double, double);
- void displayData(double, double, double);
- int main()
- {
- double length; //The rectangle's length
- double width; //The rectangle's width
- double area; //The rectangle's area
- //Finding the rectangle's length
- length = getLength();
- //Finding the rectangle's width
- width = getWidth();
- //Finding the rectangle's area
- area = getArea(length, width);
- system("cls");
- //Displaying the rectangle's data
- displayData(length, width, area);
- system("pause");
- return 0;
- }
- double getLength()
- {
- double length;
- cout << "What is the rectangle's length?" << endl;
- cin >> length;
- return length;
- }
- double getWidth()
- {
- double width;
- cout << "What is the rectangle's width?" << endl;
- cin >> width;
- return width;
- }
- double getArea(double length, double width)
- {
- double area;
- area = length * width;
- return area;
- }
- void displayData(double length, double width, double area)
- {
- cout << "The rectangle's length is " << length << endl;
- cout << "The rectangle's width is " << width << endl;
- cout << "The rectangle's area is " << area << endl << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment