class Test {
public static void main(String[] args) {
double start = 0;
double pay = 6;
double x = 0.8;
double y = 0.5;
for (int day = 1; day <= 30; day++) {
double dayPay = pay;
if (start > 150) {
dayPay = pay * y;
}
if (start > 100) {
dayPay = pay * x;
}
start += dayPay;
System.out.println("第" + day + "天的时候总共花费了" + start + "元");
}
System.out.println("一个月总共花费了" + start + "元");
}
} |