复制程式
import java.io.*;
public class ex5_10 {
public static void main(String[] args) throws IOException {
int time = 0, sum = 0, total = 0, total2 = 0, total3 = 0, total4 = 0;
InputStreamReader in = new InputStreamReader(System.in);
BufferedReader buf = new BufferedReader(in);
System.out.print("请输入整月的工作时数:");
time = Integer.parseInt(buf.readLine());
System.out.print("请输入固定时薪:");
sum = Integer.parseInt(buf.readLine());
if (sum >= 121) {
total = 60 * sum;
total2 = (int) (sum * 1.33) * 60;
total3 = (int) (sum * 1.66) * (time - 120);
total4 = total + total2 + total3;
System.out.println("薪水为:" + total4);
} else if (sum >= 61) {
total = 60 * sum;
total2 = (int) (sum * 1.33) * (time - 60);
total3 = total + total2;
System.out.println("薪水为:" + total3);
} else {
total = time * sum;
System.out.println("薪水为:" + total);
}
}
}
其实还满多小错误的也
变数名子不一样
建议可以用一些IDE来辅助编辑
还有加一些try catch来检查输入的值
上面是可以run的
不过写法是可以再改啦
小小的建议