steamengines

PA 1 Rectangle Area

Jan 15th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. /*  Christian Ballard
  2. COSC 1336 - 001
  3. PA #1 - Rectangle Area
  4. January 13, 2015
  5. */
  6.  
  7. #include <iostream>
  8. using namespace std;
  9.  
  10. // Prototypes for getLength, getWidth, getArea, and display Data functions.
  11. double getLength();
  12. double getWidth();
  13. double getArea(double, double);
  14. void displayData(double, double, double);
  15.  
  16.  
  17. int main()
  18. {
  19.     double length;  //The rectangle's length
  20.     double width;   //The rectangle's width
  21.     double area;    //The rectangle's area
  22.  
  23.     //Finding the rectangle's length
  24.     length = getLength();
  25.  
  26.     //Finding the rectangle's width
  27.     width = getWidth();
  28.  
  29.     //Finding the rectangle's area
  30.     area = getArea(length, width);
  31.  
  32.     system("cls");
  33.  
  34.     //Displaying the rectangle's data
  35.     displayData(length, width, area);
  36.  
  37.     system("pause");
  38.     return 0;
  39. }
  40.  
  41. double getLength()
  42. {
  43.     double length;
  44.     cout << "What is the rectangle's length?" << endl;
  45.     cin >> length;
  46.  
  47.     return length;
  48. }
  49.  
  50. double getWidth()
  51. {
  52.     double width;
  53.     cout << "What is the rectangle's width?" << endl;
  54.     cin >> width;
  55.  
  56.     return width;
  57. }
  58.  
  59. double getArea(double length, double width)
  60. {
  61.     double area;
  62.     area = length * width;
  63.  
  64.     return area;
  65. }
  66.  
  67. void displayData(double length, double width, double area)
  68. {
  69.     cout << "The rectangle's length is " << length << endl;
  70.     cout << "The rectangle's width is " << width << endl;
  71.     cout << "The rectangle's area is " << area << endl << endl;
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment