即使在 tprice = 75 + (2/10) * 距离发生后,它仍将最小值输入为 26。该程序不允许包含 if 语句,因此 Math.Min(tprice, cprice); 希望这是足够的信息。
class UserCalc {
public static void main(String [] args) {
int cPrice, tPrice, distance, selfCont, minValue;
double refund;
Scanner scanner = new Scanner(System.in);
System.out.println("Please enter the distance by car");
distance = scanner.nextInt();
System.out.println("Please enter the self contribution");
selfCont = scanner.nextInt();
scanner.nextLine();
tPrice = 75 + (2/10) * distance;
cPrice = 26 + (7/10) * distance;
minValue = Math.min(tPrice, cPrice);
System.out.println(minValue);
refund = minValue * (100 - selfCont)/100;
}
}