Question: Write a class called CSVReader that contains the following attributes and methods. This class will read the cellular.csv file one line at a time and

Write a class called CSVReader that contains the following attributes and methods. This class will read the cellular.csv file one line at a time and set various attributes.

Attributes:

Instance variable called countryNames, a one dimensional array of type String, which holds the names of all countries read from the CSV file.

Instance variable called yearLabels, a one dimensional array of type int, which holds the year number read from the CSV file.

Instance variable called cellularDataTable, a two dimensional array of type double, where the row represents a country, and the column represents the number of subscriptions for a specific year.

Methods:

A constructor that takes in the file name. We will use this to create a new File object and Scanner object.

Using the Scanner object, read the CSV file one line using nextLine(). See lecture notes in Modules and Java docs at (http://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html (Links to an external site.)Links to an external site.)

getCountryNames() method which returns countryNames

getYearLabels() method which returns yearLabels

getParsedTable() which returns cellularDataTable Note: TestCSVReader requires that the data file cellular.csv exists in the folder resources.

Your Java project should have a folder called resources. Store the CSV file in this folder.

Include at least one test case in addition to those provided.

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!