Note that there are some explanatory texts on larger screens.

plurals
  1. POOutput written to screen then to output file?
    text
    copied!<p>Basically I had to read in some data from an input file and do some calculations to calculate the total-staff cost per unit, the input shown below in the following format</p> <pre><code>&lt;shop unit&gt; &lt;sales assistants&gt; &lt;hours&gt; &lt;rate&gt; Unit One 4 32 8 38 6 38 6 16 7 Unit Two 0 Unit Three 2 36 7 36 7 </code></pre> <p>Goes upto 9 shop units..</p> <p>I then had to allow a user input which is the "Recommended maximum"(RM) and compare it with the total staff costs per unit. If the total staff cost per unit is less than or equal to RM then the details must be written to the screen and to an output text file called results.txt. If the amount is larger than RM then the results must be written to the screen only. Anyways here is my code below, and the bit im having problems with is the output mentioned above, Only shop unit 9 is printing to the output file and most of the time nothing prints to the console:</p> <pre><code>if (total &gt; reccomended_max) { System.out.println("The total staff wages for " + Unitnum + " is £" + total + ", therefore it is larger than the RM"); } else if (total == reccomended_max) { System.out.println("The total staff wages for " + Unitnum + " is £" + total + ", therefore it is equal to the RM"); } else { System.out.println("The total staff wages for " + Unitnum + " is £" + total + ", there it is less than the RM"); } </code></pre> <p>I have shortened my code, because it has a lot of else if statements, What design pattern is suitable for removing many if and else or else if statements?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload