Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(5) File Manipulation : (10 points) Write a void method named boyGirl that accepts a Scanner as a parameter. The Scanner is reading its input

image text in transcribed
(5) File Manipulation : (10 points) Write a void 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 t boys' integers and the sum of the girls' int not assume that it contains an even number of names. If the input file tas.txt contains the following text: egers. The input could end with either a boy or girl; you may Steve 3 Sylvia 7 Craig 14 > Lisa 13 Brian Charlotte 9 Jordan 6 then the main method could be called in the following way: public static void main(Stringl] arg)f 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: Your file contains: 4 boys and 3 girls The difference between boys' and girls' sums: 2 Notes: The file always starts with a boy, but it may or may not end with a girl. The file may be different than the one above, do not assume it is 7 people

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions

Question

How would you describe your typical day at work?

Answered: 1 week ago