Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!