0
基本上我正在阅读一个文件,其中有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即时得到:
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
看来无论输入是什么,我只得到第九单元显示在输出文件?任何人都知道为什么这可能是或我的代码太简短,不知道为什么?
您应该初始化if语句之外的输出流。其他部分不使用它。 – erny