Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a method named flipLines that accepts as its parameter a Scanner for an input file and that writes to the console the same file's

image text in transcribed

Write a method named flipLines that accepts as its parameter a Scanner for an input file and that writes to the console the same file's contents with successive pairs of lines reversed in order. For example, if the input file contains the following text: Twas brillig and the slithy toves did gyre and gimble in the wabe All mimsey were the borogroves, and the mome raths outgrabe. "Beware the Jabberwock, my son, the jaws that bite, the claws that catch Beware the JubJub bird and shun the frumious bandersnatch." The program should print the first pair of lines in reverse order, then the second pair in reverse order, then the third pair in reverse order, and so on. Therefore your method should produce the following output to the console: did gyre and gimble in the wabe. Twas brillig and the slithy toves and the mome raths outgrabe. All mimsey were the borogroves, "Beware the Jabberwock, my son, Beware the JubJub bird and shun the jaws that bite, the claws that catch, the frumious bandersnatch." Notice that a line can be blank, as in the third pair. Also notice that an input file can have an odd number of lines, as in the one above, in which case the last line is printed in its original position. You may not make any assumptions about how many lines are in the Scanner

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

Databases Organizing Information Digital And Information Literacy

Authors: Greg Roza

1st Edition

1448805929, 978-1448805921

More Books

Students also viewed these Databases questions

Question

Am I staying angry at someone, hoping to make him or her feel bad?

Answered: 1 week ago

Question

What is management growth? What are its factors

Answered: 1 week ago