Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Do Chapter 10 Exercise 11 , CopyNames : copy peoples names from an input to an output file, correcting how the names are formatted:

Java

Do Chapter 10 Exercise 11, CopyNames: copy peoples names from an input to an output file, correcting how the names are formatted:

You are given a text file containing the names of people. Every name in the file consists of a first name and last name, that is, exactly two words. Unfortunately, the programmer who created the file of names had a strange sense of humor and did not guarantee that each name was on a single line of the file.

Read this file of names and write them to a new text file, one name per line. For example, if the input file contains the lines:

Bob Jones Fred

Charles Ed

Marston

Jeff

Williams

then the output file should be:

Bob Jones

Fred Charles

Ed Marston

Jeff Williams

Hints:

You can use Scanners next method to read a single word, one at a time, from the input file.

You can assume that each name consists of exactly 2 words, and that there are only complete names in the input file.

To write out each complete name, simply read two words at a time as long as hasNext returns true and write those two words, separated by a space, to the output file.

You can ask the user for the input and output file names or read them from program command arguments.

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 2 Lnai 8725

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448505, 978-3662448502

More Books

Students also viewed these Databases questions

Question

When is the appropriate time to write a business plan?

Answered: 1 week ago