首页 > 代码库 > hohohohoho
hohohohoho
#include<stdio.h>
class Fee
{
public:
Fee(float dist,int min):m_dist(dist),m_min(min){}
void Deal();
private:
float distBased();
float timeBased();
float m_dist;
int m_min;
float m_fee;
};
void Fee::Deal()
{
if(m_dist<=2.0 && m_min<10)
{
m_fee = 6.0;
}
else
{
float fee1 = distBased();
float fee2 = timeBased();
if(fee1>fee2)
{
m_fee = fee1;
}
else
{
m_fee = fee2;
}
}
printf("%.1f\n",m_fee);
}
float Fee::distBased()
{
float fee;
fee = (int)((m_dist-2)/0.5)*0.7+6.0;
if(m_dist>7.0)
{
fee += (int)(m_dist-7)*0.7;
}
return fee;
}
float Fee::timeBased()
{
float fee;
fee = (m_min-10)/3*1.4+6.0;
return fee;
}
int main()
{
float dist;
int min;
scanf("%f %d",&dist,&min);
Fee op(dist,min);
op.Deal();
return 0;
}
hohohohoho