subject

The class shown below called is called CSVReader. Use this class exactly as it is written (specifically don’t add any instance variables) except add the code for the methods readFile, numberOfRows, numberOfFields, and field. Not that this class stores the data in a 2-dimensional ArrayList of String. You can assume that the fields in a CSV file are separated by commas. You will find it useful to have a Scanner object that reads the file line by line, and a second Scanner object that processes each line.

import java. util. Scanner;
import java. util. ArrayList;
import java. io. File;
import java. io. FileNotFoundException;

public class CSVReader
{
ArrayList> fields;
public CSVReader()
{
fields = new ArrayList>();
}
public void readFile(String filename) throws FileNotFoundException
{
File inputFile = new File (filename);
String word;
String line;
int index = 0;
Scanner in = new Scanner(inputFile);
while(in. hasNextLine())
{
line = in. nextLine();
Scanner lineScanner = new Scanner(line);
lineScanner. useDelimiter(",");
fields. add(new ArrayList());
while(lineScanner. hasNext())
{
word = lineScanner. next();
fields. get(index).add(word);
}
lineScanner. close();
index++;
}
in. close();
}
public int numberOfRows()
{
return fields. size();
}
public int numberOfFields(int row)
{
if(row < 0) {return 0;}
if(row >= fields. size()){return 0;}
return fields. get(row).size();
}
String field(int row, int column)
{
if( row >= 0 && row < fields. size()){
if(column >= 0 && column < fields. size())
{
return fields. get(row).get(column);
}
else return "";
}
else return "";
}
}

Note: Your program should ignore the first row of data (which is the column headers) even though your CSVReader class will read and store these values.
• You can assume that the names of the realtors in Realty. csv consist of a single-word first name followed by one blank followed by a single-word last name.
• The MLS number should be left justified in a field 8 characters wide
• The name should be written as Lastname, Firstname left justified in a field 20 characters wide
• The street address should be left justified in a field 20 characters wide
• The city should be left-justified in a field 12 characters wide
• The state should be left justified in a field 3 characters wide
• The zip should be left justified in a field 6 characters wide
• The price should be right justified in a field 12 characters wide, preceded by a dollar sign, with decimal separators and 2 digits of precision.
• The square footage, number of bedrooms, number of baths, and price per square foot should look like the example, with price per square foot right justified.
Include the summary information at the bottom.
M5678 Smith, Jane 606 Cardinal St. Maryville TN 37803 $230,000.00 1800 SF 4 beds 2 baths price/sf: $127.78

M3499 McCormick, Lance 418 Scenic Dr. Knoxville TN 37919 $649,000.00 3900 SF 4 beds 4 baths price/sf: $166.41
M2345 Smith, Jane 814 St. Andrew St. La Crosse WI 54601 $99,000.00 1100 SF 2 beds 1 baths price/sf: $90.00
M1265 Finley, Heather 517 Avon St. La Crosse WI 54601 $110,000.00 1200 SF 3 beds 1 baths price/SF: $91.67
M8690 Burmeister, Georgia 728 Alice Bell Rd Knoxville TN 37917 $169,000.00 2100 SF 3 beds 2 baths price/sf: $80.48
M8356 Nichols, Roger 119 Cherokee Blvd Knoxville TN 37919 $999,999.00 3800 SF 5 beds 4 baths price/sf: $263.16
M8211 Jones, Steven 619 Derby St Chattanooga TN 37404 $549,000.00 2800 SF 4 beds 3 baths price/sf: $196.07
M8044 Smith, Harold 872 La Crosse St. La Crosse WI 54603 $210,000.00 2250 SF 3 beds 2 baths price/sf: $93.33
M4789 O'Connor, Judy 4000 McArthur Ave Chattanooga TN 37404 $179,000.00 1675 SF 3 beds 3 baths price/sf: $106.87
M9000 Smith, Alice 1901 3rd St. Chattanooga TN 37411 $158,000.00 2400 SF 3 beds 3 baths price/sf: $65.83
There is a total of 10 homes on the market with an average price of $335,299.90

Using the class provided above make a Tester method that prints out the file provided Realty. csv as well as making sure other files like Realty. csv can also be used in the Tester made us the Class provided. Make it to where any CSV file can be used by hardcoding it in but for this question only focus on the file shown
CSV File contents:
MLS Realtor name Street Address City State Zip Price square footage number of bedrooms number of bathrooms
M5678 Jane Smith 606 Cardinal St. Maryville TN 37803 230000 1800 4 2
M3499 Lance McCormick 418 Scenic Dr. Knoxville TN 37919 649000 3900 4 4
M2345 Jane Smith 814 St. Andrew St. La Crosse WI 54601 99000 1100 2 1
M1265 Heather Finley 517 Avon St. La Crosse WI 54601 110000 1200 3 1
M8690 Georgia Burmeister 728 Alice Bell Rd Knoxville TN 37917 169000 2100 3 2
M8356 Roger Nichols 119 Cherokee Blvd Knoxville TN 37919 999999 3800 5 4
M8211 Steven Jones 619 Derby St Chattanooga TN 37404 549000 2800 4 3
M8044 Harold Smith 872 La Crosse St. La Crosse WI 54603 210000 2250 3 2
M4789 Judy O'Connor 4000 McArthur Ave Chattanooga TN 37404 179000 1675 3 3
M9000 Alice Smith 1901 3rd St. Chattanooga TN 37411 158000 2400 3 3

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 07:00
Why were most movies from the late 1890s until the early 1930s only filmed in black and white? there were only a few people who could afford the technology to produce color motion pictures back then. audiences did not want color motion pictures until later. the film used to make color motion pictures often overheated, which was a safety hazard, so it was generally not allowed. color films had to be hand-colored, frame by frame.
Answers: 3
question
Computers and Technology, 23.06.2019 11:20
Http is the protocol that governs communications between web servers and web clients (i.e. browsers). part of the protocol includes a status code returned by the server to tell the browser the status of its most recent page request. some of the codes and their meanings are listed below: 200, ok (fulfilled)403, forbidden404, not found500, server errorgiven an int variable status, write a switch statement that prints out the appropriate label from the above list based on status.
Answers: 2
question
Computers and Technology, 23.06.2019 13:30
Spoons are designed to be used for: spring hammering. applying body filler. identifying high and low spots. sanding highly formed areas.
Answers: 3
question
Computers and Technology, 23.06.2019 15:30
Write a program in plp assembly that counts up by one starting from zero (or one) inside a loop and writes this value to the leds every time the value is increased. the memory address of the leds is 0xf0200000. the table below shows the meaning and an example usage of the instructions covered in the video, plp instructions for project 1. instruction example usage meaning load immediate li $t0, 8 register $t0 is set to the value, 8. store word sw $t2, 0($t1) the value in register $t1 is used as the memory address. the value in register $t2 is copied into this memory address. add addiu $t4, $t3, 29 register $t4 is assigned the sum of 29 and the value in register $t3. jump j your_label_name the program jumps to the line following the label, "your_label_name: ". label your label name: defines a label called "your_label_name: " that can be jumped to
Answers: 2
You know the right answer?
The class shown below called is called CSVReader. Use this class exactly as it is written (specifica...
Questions