基本上我正在阅读一个有9个商店单位的文件,然后是他们的一堆代码,从中做了一堆计算,无论如何我有问题,我只是得到一些输出。这是我的代码:
}
if(total > reccomended_max){
PrintStream out = new PrintStream(new FileOutputStream("output.txt"));
System.setOut(out);
System.out.println("The total staff wages for " + Unitnum + " is £" +total + ", therefore it is higher than the RM");
}else{
System.out.println("The total staff wages for " + Unitnum + " is £" +total + ", therefore it is lower than the RM");
}
“reccomended_max”是一个用户输入数字,然后基本上如果商店单位的“总”工资大于“recommended_max”我需要它:
将车间单位数据打印到输出文件
其他>如果它小于... orint到控制台.. 当我为reccomended_max im尝试随机数输入时:
Please enter the recommended maximum(RM) staff cost:
900
The total staff wages for Unit One is £824.0, therefore it is lower than the RM
The total staff wages for Unit Two is £0.0, therefore it is lower than the RM
The total staff wages for Unit Three is £504.0, therefore it is lower than the RM
要控制^^。并输出文件: 第九单元的员工工资总额为935.0英镑,因此高于RM
无论输入是什么,我只在输出文件中显示单元9?任何人都知道为什么这可能是或者我的代码太简短而不知道为什么??
答案 0 :(得分:0)
尝试放PrintStream out = new PrintStream(new FileOutputStream("output.txt"));
在if语句之外。想想也许这就是问题所在,但我还是个初学者,所以不要抱我这么做!