职位关键字 工作地点
工作名称 公司名称 校园招聘
中国最好的工作搜索引擎!
  回复留言  
  上海市出租汽车计费的算法 用流程图 高中信息
作者: yayamy  01-01 08:00   回复  
 上海市出租汽车计费的算法 用流程图 高中信息

悬赏分:50 - 离问题结束还有 14 天 23 小时

上海市出租车计费的算法 用流程图 高中信息



请用流程图描述"上海出租车计费的算法"

1.基本条件

出租车起步价10元(3公里);超3公里后每公里计价2元;超10公里没公里计价3元

2.函数关系

经整理,车费y1(元)与行车里程x(公里)之间的关系可表示为

10 0<X<=3

Y1=2*X+4 3<X<=10

3*X-6 X>10

3.请画出流程图 谢谢 3天内正确答复~~~多追加25积分 谢谢~~~

由于这里不能画 请发送到 YE606390@SINA.COM 著明名字 加分用

  回复:上海市出租汽车计费的算法 用流程图 高中信息
作者: eason0010  01-01 08:00   回复  
 java 的里面的起步价啊什么的你根据上海的价格改一下就好了

import java.util.*;

class Taxi{

float len; \\公里

float start_price; \\起价

float start_len=3; \\起始里程

float per_price; \\每公里价格

float price ; \\总价

//设置起始价和每公里价格

public void set_price(){

int curr_hour =Calendar.get.instance().get(Calendar.HOUR_OF_DAY);

if (curr_hour=7&&curr_hour<=23){

start_price=10;

per_price=1.2f;

}

else {

start_price=11;

per_price=1.4f;

}

}

public void calc(flaot len){

this.len=len;

set_price();

if (len<=start_len)price=start_price;

else price=start_price+per_price*(len-start_len);

//格式化输出结果

//price=(float)(Math.floor(price*10)/100);

price=Math.round(price);

}

public void show(){

System.out.println("起价:"+start_price);

System.out.println("起始公里:"+start_len);

System.out.println("每公里价格:"+per_price);

System.out.println("里程:"+len);

System.out.println("================================");

System.out.println("总价:"+price);





public class CalcTaxi{

public static void main(String[]args){

Taxi tal =new Taxi();

int len=0;

try{

len=integer.parseInt(args[0]);

}catch(NumberFormatException ee){

System.out.println("输入合法公里数!");

return;

}

tal.calc(len):

tal.show();

}

}

标 题:
内 容:
用户名:
 游客
 
 
Copyright©2005-2007, 版权所有 WWW.JOBMET.COM
ICP证:京ICP备06019556号