fork download
    #include <iostream>
    using namespace std;
     
    class rectangle {
    private:
    float Width;
    float Length;
     
    public:
    //Contstructor
    rectangle(float w=1, float l=1);
     
    float GetWidth();
    void SetWidth(float w);
     
    float GetLength();
    void SetLength(float l);
     
    float Area();
    float Perimeter();
    float draw();
    };	
     
     
    rectangle::rectangle(float w, float l):Width(w), Length (l) {}
     
     
    //width
    float rectangle::GetWidth()
    {
    return Width;
    };
     
    void rectangle::SetWidth(float w)
    {
    Width = w;
    float userWidth;
    cout << "Enter a width between 0 and 20.0: "; cin >> userWidth;
    while (userWidth >= 20 || userWidth < 0)
    {
    cout << "Enter a width between 0 and 20.0: ";
    cin >> userWidth;
    }
    };
     
     
    //Length
    float rectangle::GetLength()
    {
    return Length;
    };
     
    void rectangle::SetLength(float l)
    {
    Length = l;
    float userLength;
    cout << "Enter a width between 0 and 20.0: "; cin >> userLength;
    while (userLength >= 20 || userLength < 0)
    {
    cout << "Enter a width between 0 and 20.0: ";
    cin >> userLength;
    }	
    };
     
     
    //calculations
    float rectangle::Area()
    {
    return Width*Length;
    };
    float rectangle::Perimeter()
    {
    return 2*(Width+Length);
    };
     
     
    int draw() {
    float Length = (float) 3.11, Width = (float) 5.99;
    int Length_int, Width_int;
    Length_int = (int) Length;
    Width_int = (int) Width;
    for(int i = 0; i < Length_int; i++)
    {
    for (int i = 0; i < Width_int; i++)
    cout << '+';
    cout << endl;
    }
    return 0;
    };
     
     
    int main(){
     
    rectangle r1(2,3);
    cout << "Width: " << r1.GetWidth() << " \nHeight: " << r1.GetLength() << "\nArea: " << r1.Area() << "\nPerimeter: " << r1.Perimeter() << endl;
     
    system("pause");
    return 0;
    }; 
Success #stdin #stdout #stderr 0s 3296KB
stdin
Standard input is empty
stdout
Width: 2 
Height: 3
Area: 6
Perimeter: 10
stderr
sh: pause: not found