某城市出租车计费问题: 每日06:00-21:00,起步价6元,当日22:00-次日05:00
答案:2 悬赏:70
解决时间 2021-03-03 18:58
- 提问者网友:恋你成殇
- 2021-03-03 04:06
某城市出租车计费问题: 每日06:00-21:00,起步价6元,当日22:00-次日05:00,起步价7元。 起步价包含2公里,超出部分按照每公里1.5元收费。 每次乘车加收1元的燃油附加税。 输入打车的时间和距离,计算本次打车的费用。
最佳答案
- 二级知识专家网友:夢想黑洞
- 2021-03-03 05:19
import java.util.Scanner;
public class Demo {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("输入距离:");
int longth = scan.nextInt();
System.out.print("输入时间(只输入小时):");
int time = scan.nextInt();
double jutiprice = 0;
int price = 0;
int ranyou = 1;
scan.close();
if (time > 8 && time < 21) {
int start = 6;
if (longth <= 2) {
price = start;
} else {
jutiprice = (start + (longth - 2) * 1.5);
if (jutiprice - (int) jutiprice >= 0.5) {
price = (int) jutiprice + 1;
} else {
price = (int) jutiprice;
}
}
} else {
int start = 7;
if (longth <= 2) {
price = start;
} else {
jutiprice = (start + (longth - 2) * 1.5);
if (jutiprice - (int) jutiprice >= 0.5) {
price = (int) jutiprice + 1;
} else {
price = (int) jutiprice;
}
}
}
System.out.println(price + ranyou);
}
}
public class Demo {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("输入距离:");
int longth = scan.nextInt();
System.out.print("输入时间(只输入小时):");
int time = scan.nextInt();
double jutiprice = 0;
int price = 0;
int ranyou = 1;
scan.close();
if (time > 8 && time < 21) {
int start = 6;
if (longth <= 2) {
price = start;
} else {
jutiprice = (start + (longth - 2) * 1.5);
if (jutiprice - (int) jutiprice >= 0.5) {
price = (int) jutiprice + 1;
} else {
price = (int) jutiprice;
}
}
} else {
int start = 7;
if (longth <= 2) {
price = start;
} else {
jutiprice = (start + (longth - 2) * 1.5);
if (jutiprice - (int) jutiprice >= 0.5) {
price = (int) jutiprice + 1;
} else {
price = (int) jutiprice;
}
}
}
System.out.println(price + ranyou);
}
}
全部回答
- 1楼网友:我颠覆世界
- 2021-03-03 05:38
期待看到有用的回答!
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯