码迷,mamicode.com
首页 > 其他好文 > 详细

hohohohoho

时间:2014-09-12 11:45:03      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:io   c   amp   r   as   return   print   class   ca   

#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

标签:io   c   amp   r   as   return   print   class   ca   

原文地址:http://www.cnblogs.com/johnsblog/p/3967960.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!