Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Intro to Java Programming 1. Implement the method getSequence that takes a Scanner as a parameter. It should read Strings one line at a time

Intro to Java Programming

1. Implement the method getSequence that takes a Scanner as a parameter. It should read Strings one line at a time from the Scanner and store them in an ArrayList until it reaches a line with a single '.' character on it. It should then return the array list to the calling program.

public static ArrayList getSequence(Scanner in)

2. Now implement the method summarizeSequences that takes a String as a parameter. This method should open the file named by this String, and read a sequence from that file into an array list using the getSequence method you wrote above. It should then display on a single line the first, last, and middle String in the sequence (if the list is even, the position of the "middle" String is the size of the list divided by 2). Make sure you catch and handle the possible IOException exceptions.

public static void summarizeSequences(String fileName) 

3. Now implement the method writeSequenceReverse that takes a PrintWriter and an ArrayList as parameters. This method shouldwrite the Strings in the ArrayList to the PrintWriter in reverse order and then write a line with a single '.' on it.

public static void writeSequenceReverse(PrintWriter out, ArrayList list) 

4. Now implement a method reverseSequences that takes two Strings as parameters. The first String is the name of an input file containing String values and the second is the name of an output file to write the reverse sequences to. The method should read sequences from the input file one sequence at a time using getSequence and then write them out to the output file. Do not forget to close the output file when the method is finished. Make sure you catch and handle the possible IOExceptionexceptions.

public static void reverseSequences(String inputFile, String outputFile)

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

Sql All In One For Dummies 7 Books In One

Authors: Allen G Taylor ,Richard Blum

4th Edition

1394242298, 978-1394242290

More Books

Students also viewed these Databases questions