[java]代码库
package c;
import java.util.Scanner;
public class FuZi {
public static void main(String[] args) {
boolean atmight;
atmight = false;
Scanner in = new Scanner(System.in);//定义scanner,等待输入
double charge = 0;
System.out.println("请输入距离数");
double distance = in.nextDouble();
System.out.println("请输入是否为夜间数(1--夜间,0--非夜间)");
int a = in.nextInt();
System.out.println("请输入时间数");
double time = in.nextDouble();
if(a == 1){
atmight = true;
}
if(distance <3){
charge = 8;
}
else {
charge =(int)(distance + 0.9- 3) * 1.5 + 8;
}
charge +=(int)(time / 20)*10;
if(atmight == true) {
charge =(int)(distance + 0.9- 3) * 2 + 8;
charge +=(int)(time / 20)*20;
}
System.out.println("打车费共计:");
System.out.println(charge);
}
}