Kemal Sokolovic wrote:For your first issue, where the program skips the line while reading the input, you should add input.nextLine() after last input.nextInt() for each employee. The problem is that input.nextInt() reads only the integer value, and \n character (as a result from pressing return) is picked up by the following input.nextLine(). So, something like this:
Next, why you use for loop here, when you only access single element from array:
Finally, the main issue here is a result of a wrong logic in your for loop (lines 196-209 of your code). In this case info[i][j] contains number of hours worked per each day, not the payment per day. But you're still trying to add it to your total so what you're actually doing is calculating total number of hours worked per week. Also, you're printing totalScore in your inner for loop, which results in getting incorrect output; that should be moved after the end of the inner for loop.
Kemal Sokolovic wrote:In that for loop we were discussing, you are actually always accessing empoyee with index 0 (the first employee). I thought you put that just for testing purposes, since there were some commented parts.
This for loop:
should be the right one.
If you followed all directions, the program should give this output:
As I understood, this is the output you're expecting.
Note that I commented those two for loops following the one we're discussing about, because I don't really see their point (they are supposed to do some calculations, but implementing the same wrong logic). If they are supposed to actually do something, you'll need to provide more details.
Excellent, it all works just fine now! There's just a bit more left to the program that I hadn't mentioned earlier because I wasn't focused on it at the time. The program needs to calculate and display the minimum and maximum amounts per day and for the whole week, along with the corresponding employee's names. For example: "On Monday, Bill had the maximum amount with 50, and John had the minimum amount with 15. On Tuesday, Carol had the maximum amount with 35, and Bill had the minimum amount with 12... For the whole week, John had the maximum amount with 150, and Carol had the minimum amount with 120." That should be all that's left to finish.
Kemal Sokolovic wrote:You commented the line 197 where you were initializing array you were using in your original code. You are now initializing it at line 201 as 1-length array, but at line 211 that throws the exception you are accessing totalScore[i] where i has the value of 2 in second iteration. Either uncomment and use previous declaration, or declare totalScore as int variable, not an array, and change the rest of the code that used an array to use just variable.
Kemal Sokolovic wrote:Glad it's all ok now.
For the other part, you'll have to come up with some solution, and if it's not working come back here to resolve it. Nobody here will implement that for you.
edit: By the way, welcome to the Ranch!