大家帮忙看下这段代码算不算用了类的思想呢
#include<iostream.h>class CPetrol
{
private:
double price,gross,quantity;
public:
void Setinfo(double p,double g)
{
double sum;
quantity=0;
price=p;
gross=g;
sum=price*gross;
quantity+=sum;
}
void display( )
{
cout<<"今天总收入为"<<quantity<<endl;
}
};
void main()
{
CPetrol gas;
int j,a,b,c;
char k;
k='y';
for(;k=='y';)
{
cout<<"请选择汽油品种:"<<endl;
cout<<"1. 90号汽油"<<endl;
cout<<"2. 93号汽油"<<endl;
cout<<"3. 98号汽油"<<endl;
cout<<"4. 显示今天的总收入"<<endl;
cin>>j;
switch(j)
{
case 1:
{
cout<<"输入90号汽油今天的加油量:"<<endl;
cin>>a;
gas.Setinfo(3.96,a);
};break;
case 2:
{
cout<<"输入93号汽油今天的加油量:"<<endl;
cin>>b;
gas.Setinfo(4.05,b);
};break;
case 3:
{
cout<<"输入90号汽油今天的加油量:"<<endl;
cin>>c;
gas.Setinfo(4.38,c);
};break;
case 4: gas.display( );
}
cout<<"要继续吗<y/n>"<<endl;
cin>>k;
}
}