运行以下java语句时
if (padalaAmount >= 1 && padalaAmount <= 500)
charge = 150;
totalPay = padalaAmount + charge;
else
if (padalaAmount >= 501 && padalaAmount <= 1000)
charge = 300;
totalPay = padalaAmount + charge;
else
if (padalaAmount >= 1001 && padalaAmount <= 5000)
charge = 400;
totalPay = padalaAmount + charge;
else
if (padalaAmount >= 5001 && padalaAmount <= 10000)
charge = 700;
totalPay = padalaAmount + charge;
outFile.printf("%-12s %12-s %d %d %d", firstName, lastName, `padalaAmount, charge, totalPay);`
我遇到了以下编译错误:
at java.util.Formatter.checkText(Formatter.java:2547)
at java.util.Formatter.parse(Formatter.java:2523)
at java.util.Formatter.format(Formatter.java:2469)
at java.io.PrintWriter.format(PrintWriter.java:905)
at java.io.PrintWriter.printf(PrintWriter.java:804)
at Pera.main(Pera.java:59)
请帮帮我。截止日期是星期五。谢谢。
答案 0 :(得分:3)
你必须在12之后删除减号:
outFile.printf("%-12s %12s %d %d %d %n", firstName, lastName, padalaAmount, charge, totalPay);