Question: Question Number One: Write a static method blueGreen that accepts as a parameter a Scanner that reads its input from a file containing a series
Question Number One: Write a static method blueGreen that accepts as a parameter a Scanner that reads its input from a file containing a series of names followed by integers. The names alternate between blue team member names and green team member names. Your method should compute the absolute difference between the sum of the blue teams' integers and the sum of the green teams' integers. The input could end with either a blue or green team member; you may not assume that it contains an even number of names. If the input file score.txt contains the following text, Chad 3 James 7 Noah 14 Jimmy 13 Nancy 4 KK 12 Joey 6 Mitchelle 0 Then your method could be called in the following way: Scanner input = new Scanner(new File("score.txt")); blueGreen(input); And produces this console output, since the blue team's sum is 3+14+4+6 = 27 and the green team's sum is 7+13+12+0 = 32: 4 blue, 4 green Difference between blue team and green team sums: 5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
