Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Show Header O BJP3 Exercise 6.1: boyGirl Favorite Language/Type: 4 Java file processing Scanner Author: Jason Ganzhorn (on 2013/04/01) Write a method named boyGirl that
Show Header O BJP3 Exercise 6.1: boyGirl Favorite Language/Type: 4 Java file processing Scanner Author: Jason Ganzhorn (on 2013/04/01) Write a method named boyGirl that accepts a Scanner as a parameter. The Scanner is reading its input from a file containing a series of names followed by integers. The names alternate between boys' names and girls' names. Your method should compute the absolute difference between the sum of the boys' integers and the sum of the girls integers. The input could end with either a boy or girl; you may not assume that it contains an even number of names. If the input file tas.txt contains the following text: Steve 3 Sylvia 7 Craig 14 Lisa 13 Brian 4 Charlotte 9 Jordan 6 then your method could be called in the following way Scanner input - new Scanner(new File("tas.txt")); boyGirl(input); and should produce the following output, since the boys' sum is 27 and the girls' sum is 29: 4 boys, 3 girls Difference between boys' and girls' sums: 2 Type your solution here: 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started