Question: my main concern is how to create the loop for reading only 4 lines from the five-line and ignore the fifth line? Create a double
my main concern is how to create the loop for reading only 4 lines from the five-line and ignore the fifth line?
Create a double variable called totalScoringAverage.oCreate a loop. In each iteration of the loop, read five lines from team.txtand pass the first four of the five strings (lines) to createPlayer()(ignoring the fifth line, "-----"). To read the file, use File and Scanneras shown in this week's lecture. Depending on your computer, you may need to prefix team.txt with the full file path, There should be a total of 50 lines read in (10 players, 5 lines each). Your loop should not run a hard-coded number of times; it should end when Scanner's hasNextLine()returns false. When createPlayer()is called for each of the 10 players, add the returned value to totalScoringAverage.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
