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
public static ArrayListgetSequence(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
public static void writeSequenceReverse(PrintWriter out, ArrayListlist)
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started