Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use the method you created in the first part to flip the array in the file in the second part, storing the values into a

Use the method you created in the first part to flip the array in the file in the second part, storing the values into a new String[] called finalized. HELP!

import java.util.Arrays;

import java.io.File;

import java.io.FileNotFoundException;

import java.util.Scanner;

public class assignment4 {

private static String[] flipArray(String[] arr) {

String[] flipArray = new String[arr.length];

for (int i = 0; i < arr.length; ++i) {

flipArray[i] = arr[arr.length - i - 1];

}

return flipArray;

}

public static void main(String[] args) {

String[] array = {"A", "B", "C"};

System.out.println(Arrays.toString(flipArray(array)));

String output = "";

Scanner userInput = new Scanner(System.in);

System.out.print("Please enter a file name: ");

String fileName = userInput.nextLine();

File inputFile = new File(fileName);

try {

Scanner sc = new Scanner(inputFile);

while (sc.hasNextLine()) {

output += sc.nextLine() + " ";

}

sc.close();

} catch (FileNotFoundException e) {

System.err.println("File not found, please try again");

} finally {

userInput.close();

}

System.out.println(output);

}

}

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_2

Step: 3

blur-text-image_3

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

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions

Question

What is computer neworking ?

Answered: 1 week ago

Question

How do you monitor the effectiveness of the coaches?

Answered: 1 week ago

Question

How will you get the support you need?

Answered: 1 week ago

Question

How will you deal with them?

Answered: 1 week ago