Advertisement
jenniferleigh52

Rectangle Area/Burgess

Aug 17th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.98 KB | None | 0 0
  1. // Rectangle Area
  2. // Jennifer Burgess and Julie Miller
  3. // CSCI 193
  4. // Program #24
  5. // 7/24/14
  6. /*The Program will ask the user to enter the width and length of a rectangle, and then display the rectangle's
  7. area by calling functions*/
  8.  
  9. #include "stdafx.h"
  10. #include <iostream>
  11. #include <iomanip>
  12. using namespace std;
  13.  
  14. // Write the prototypes for the getLength,
  15. // getWidth, getArea, and displayData
  16. // functions here.
  17. double getLength();
  18. double getWidth();
  19. double getArea(double, double);
  20. double displayData(double, double, double);
  21.  
  22. int main()
  23. {
  24.     double length; // The rectangle's length
  25.     double width; // The rectangle's width
  26.     double area; // Multiplying Length * Width
  27.     double num; // The rectangle's area
  28.  
  29.     cout << "Hello. " << endl;
  30.    
  31.     // Calling variables.
  32.     // Get the rectangle's length.
  33.     length = getLength();
  34.  
  35.     // Get the rectangle's width.
  36.     width = getWidth();
  37.  
  38.     // Get the rectangle's area.
  39.     area = getArea(length, width);
  40.  
  41.     // Display the rectangle's data.
  42.     displayData(length, width, area);
  43.  
  44.     return 0;
  45. }
  46.  
  47. //***************************************************
  48. // You must write the getLength, getWidth, getArea, *
  49. // and displayData functions.                       *
  50. //***************************************************
  51.  
  52. double getLength() //Function Header
  53. {
  54.     double length;
  55.  
  56.     cout << "Enter the length of the triangle and press enter." << endl;
  57.     cin >> length;
  58.     return length;
  59. }
  60.  
  61. double getWidth() //Function Header
  62. {
  63.     double width;
  64.  
  65.     cout << "Enter the width of the triangle and press enter." << endl;
  66.     cin >> width;
  67.     return width;
  68. }
  69.  
  70. double getArea(double length, double width) //Function Header
  71. {
  72.     return length * width;
  73. }
  74.  
  75. double displayData(double length, double width, double area) //Function Header
  76. {
  77.     cout << "The length of the triangle is " << setw(3) << length << endl;
  78.     cout << "The width of the triangle is " << setw(4) << width << endl;
  79.     cout << "The area of the triangle is " << setw(5) << area << endl;
  80.     return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement