Advertisement
Guest User

Clippy duz mooth

a guest
Oct 20th, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4.  
  5. double getWidth(){
  6.     double width = 0;
  7.     while(width<=0){
  8.         cout << "Enter the width of the rectangle." << endl;
  9.         cin >> width;
  10.     }
  11.     return width;
  12. }
  13.  
  14. double getLength(){
  15.     double length = 0;
  16.     while(length <=0){
  17.         cout << "Enter the length of the rectangle." << endl;
  18.         cin >> length;
  19.     }
  20.     return length;
  21. }
  22.  
  23. double getArea(double w,double l){
  24.     return (w*l);
  25. }
  26.  
  27. void displayData(double w, double l, double a){
  28.     cout << "*Ahem* Drum roll please! Here is the results of a finely calculated calculations!." << endl;
  29.     cout << "For a rectangle with the width of: " << w << ", a length of: " << l << ", the area is: " << a << endl;
  30. }
  31.  
  32. int main(){
  33.     double width,length,area;
  34.     cout << "*Clippy Appears* Hey I see you're trying to calculate the area of a rectangle, let me help you with that." << endl;
  35.     width = getWidth();
  36.     length = getLength();
  37.     area = getArea(width,length);
  38.     displayData(width,length,area);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement