Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with completing this program which is to reads data from a file and stores it in a two-dimensional array and then uses

I need help with completing this program which is to reads data from a file and stores it in a two-dimensional array and then uses nested for-loop to print the values in a table format. I was trying to use this text file below:

The following retailers below made Glassdoor's 100 Best Places to Work - U.S. list.

1. (Rank: 9) lululemon

Company Rating: 4.5

2. (Rank: 32) Trader Joe's

Company Rating: 4.4

3. (Rank: 33) H E B

Company Rating: 4.4

4. (Rank: 55) eBay

Company Rating: 4.3

5. (Rank: 56) Apple

Company Rating: 4.3

6. (Rank: 78) Este Lauder Companies

Company Rating: 4.2

7. (Rank: 80) Wegmans Food Markets

Company Rating: 4.2

8. (Rank: 84) Vans

Company Rating: 4.2

9. (Rank: 88) Madewell

Company Rating: 4.2

10. (Rank: 90) Scheels

Company Rating: 4.2

11. (Rank: 93) Costco Wholesale

Company Rating: 4.2

12. (Rank: 95)REI

Company Rating: 4.2

13. (Rank: 98) Malouf Companies

Company Rating: 4.2

This how far I got: Please assist with the correct java code for program.

import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException;

/** * */

/** * @author * */ public class FileIO {

public static void main(String[] args) {

String[] companies = {"lululemon", "Trader Joe's", "H E B", "eBay", "Apple"}; try { BufferedWriter writer = new BufferedWriter(new FileWriter("output.txt")); writer.write("The following retailers below made Glassdoor's 100 Best Places to Work - U.S. list."); for (int i = 0; i < companies.length; i++) { writer.write(" \"lululemon\", \"Trader Joe's\", \"H E B\", \"eBay\", \"Apple\""); } writer.close(); } catch (IOException e) { e.printStackTrace(); }

}

}

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

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions

Question

Define deferred revenue. Why is it a liability?

Answered: 1 week ago