问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
#include<iostream>
using namespace std;
class rectangle
{
private:
float length=0.0;
float width=0.0;
public:
void setlength()
{
//cout<<"输入length:";
cin>>length;
}
void setwidth()
{
//cout<<"输入width:";
cin>>width;
}
/*****************************************************/
float getlength()
{
cout<<"length: "<<length;
}
float getwidth()
{
cout<<"width: "<<width;
}
/******************************************************/
void setrange()
{
if(0.0<length<20.0&&0.0<width<20.0)
{
cout<<"length and width are both in 0.0 - 20.0"<<endl;
}
else if(0.0<length<20.0!=1)
{
cout<<"length is not in 0.0 - 20.0"<<endl;
}
else if(0.0<width<20.0!=1)
{
cout<<"width is not in 0.0 - 20.0"<<endl;
}
}
/************************计算周长******************************/
void Perimeter()
{
int Per=(length+width)*2;
cout<<"Perimeter: "<<Per<<endl;
}
/*************************计算面积**********************************/
void Area()
{
int A=length*width;
cout<<"Area: "<<A<<endl;
}
/*******************************************************************************************************************/
};
int main()
{
rectangle R;
R.setlength();R.setwidth();
R.getlength();cout<<" ";R.getwidth();
cout<<endl;
R.setrange();
R.Perimeter();
R.Area();
system("pause");
return 0;
}
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/801939891846166.png "#left")
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果