Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- double getWidth(){
- double width = 0;
- while(width<=0){
- cout << "Enter the width of the rectangle." << endl;
- cin >> width;
- }
- return width;
- }
- double getLength(){
- double length = 0;
- while(length <=0){
- cout << "Enter the length of the rectangle." << endl;
- cin >> length;
- }
- return length;
- }
- double getArea(double w,double l){
- return (w*l);
- }
- void displayData(double w, double l, double a){
- cout << "*Ahem* Drum roll please! Here is the results of a finely calculated calculations!." << endl;
- cout << "For a rectangle with the width of: " << w << ", a length of: " << l << ", the area is: " << a << endl;
- }
- int main(){
- double width,length,area;
- cout << "*Clippy Appears* Hey I see you're trying to calculate the area of a rectangle, let me help you with that." << endl;
- width = getWidth();
- length = getLength();
- area = getArea(width,length);
- displayData(width,length,area);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement