怎么样修改?
停车场三小时内的最少收费2。00美元,超过三小时每增加一小时需要收取0。5美元的附加费,24小时之内的最多收费是10美元,假设没有车子一次停车超过24小时。编写一个程序,计算并显示昨天的天个客户各自的停车费用,输出使用下面的格式:car hour charge
1 1.50 2.00
2 4.0 2.50
3 24.0 10.00
Total 29.5 14.50
下面是我写的程序:(和要求不一样,请各位帮忙看看是哪里错了)
#include <iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{float h,h1,h2,h3,ch,ch1,ch2,ch3,t1,t2;
cout<<"Enter hour: ";
cin>>h1>>h2>>h3;
h=h1,h2,h3;
if(h>0&&h<=3)
{ch=2.00;
cout<<ch<<endl;
}
else if(h>3&&h<=19)
{
ch=0.5*h+0.5;
cout<<ch<<endl;
}
else
{ch=10.00;
cout<<ch<<endl;
}
if(h=h1)
{ch1=ch;
}
else if(h=h2)
{ch2=ch;
}
else
{ch3=ch;
}
t1=h1+h2+h3;
t2=ch1+ch2+ch3;
cout<<setiosflags(ios::fixed)<<setprecision(2);
cout<<"\t"<<"car"<<"\t\t"<<"hour"<<"\t\t"<<"charge"<<endl;
cout<<"\t"<<1<<"\t\t"<<h1<<"\t\t"<<ch1<<endl;
cout<<"\t"<<2<<"\t\t"<<h2<<"\t\t"<<ch2<<endl;
cout<<"\t"<<3<<"\t\t"<<h3<<"\t\t"<<ch3<<endl;
cout<<"\t"<<"Total"<<"\t\t"<<t1<<"\t\t"<<t2<<endl;
return 0;
}
和要求不一样请各位帮忙看看是哪里错了。谢谢了。