1 Description CSV is a very simple text-based format that represents tables of data: Every...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1 Description CSV is a very simple text-based format that represents tables of data: ● Every row is on its line Every column value is separated by a comma. For example, the table 1 3410 2 2 3 4 1,2,3,4 3,4,1,0 2,3,4,2 3 4 2 would correspond to the text file containing: In this assignment, your program will need to read a CSV file, parse it to extract the contents, and build a 2D array of type double that will store the data. Then, it needs to some simple math on the 2D array of data, such as compute averages and find min/max values. This 2D array can have an arbitrary number of rows/columns, so do not hard-code any specific dimensions. You are provided with the skeleton of the solution. The class CSVReader has a method readFile() that opens the specified file and returns its contents as one string. So, for above example, readFile would return the string: "1,2,3,4\n3,4,1,0\n2,3,4,2" You will need to parse this string and extract the data using the split() method of the String: First, split the entire string into "line" tokens, where each token represents a row in the final matrix of data. The number of tokens is the number of rows in the 2D array of doubles. Then, you split each line token to extract individual numeric values. The number of tokens is the number of columns in the 2D array of doubles. At this point, you can allocate your double[][] array. All this functionality will go into the class called DataMatrix, which will contain the 2D array of doubles (as a private instance variable), as well as a method for initializing it based on a single String. Once you have your DataMatrix class initializing 2D array of doubles, you will need to write at least five additional methods for DataMatrix: ● ● You can then loop through your tokens and convert each string containing a number - e.g. "1" - into a double value using the static method Double.parse Double(). This double value would then go into your 2D array of doubles at the appropriate location. ● A method that calculates and returns the average value for every row: public double[] rowAverage(); A method that calculates and returns the average value for every column: public double[] columnAverage(); A method that calculates and returns the overall average value for the data: public double[] matrixAverage(); A method that calculates and returns the minimum value in the data: public double minValue(); A method that calculates and returns the maximum value in the data: public double maxValue(); Make sure the above methods return the data, instead of displaying it. In other words, they must have double as the return type, and contain no print statements. It is also recommended that you implement a method for displaying the 2D array on the screen, so you can compare it to the CSV file and verify that your parser works correctly. How you do this is up to you. 2 Implementation Your assignment will consist of the following three classes: CSVReader - provided by me. Contains the code for a reading date from a file. Don't modify it DataMatrix - must be written by you from scratch. It will implement all of the functionality for your data matrix ● Assignment2 - a class with the main() method. I provide you with a skeleton that you must expand. The purpose of this class is to test the DataMatrix class and its methods. Your code will have only one main() method, provided in the Assignment2 class. Do not put main methods anywhere else! Assignment2 takes the name of the CSV file as the common line argument. In the main method of Assignment2, you will need to do the following: Load a CSV file into a String. This is already done in the skeleton file provided for you. Create one DataMatrix object and initialize it using the string you've just read in • After this, use the appropriate methods of the DataMatrix object to calculate and display: You can assume that the CSV file is correctly formatted and every row has the exact same number of values. 3 Evaluation Your code must compile, run, and have all of the above functionality implemented according to the object-oriented programming (OOP) principles covered in class. Any compiler errors will result in the automatic grade of zero (0) for the assignment. Make sure to have ● o The average value for every row o The average value for every column o The overall average value for the data o The minimum value in the data o The maximum value in the data ● Follow submission instruction Correct and nom-missing functionality No Run-time errors No Compiler warnings Good indentation Good variable names Good OOP practices Sufficient comments 1 Description CSV is a very simple text-based format that represents tables of data: ● Every row is on its line Every column value is separated by a comma. For example, the table 1 3410 2 2 3 4 1,2,3,4 3,4,1,0 2,3,4,2 3 4 2 would correspond to the text file containing: In this assignment, your program will need to read a CSV file, parse it to extract the contents, and build a 2D array of type double that will store the data. Then, it needs to some simple math on the 2D array of data, such as compute averages and find min/max values. This 2D array can have an arbitrary number of rows/columns, so do not hard-code any specific dimensions. You are provided with the skeleton of the solution. The class CSVReader has a method readFile() that opens the specified file and returns its contents as one string. So, for above example, readFile would return the string: "1,2,3,4\n3,4,1,0\n2,3,4,2" You will need to parse this string and extract the data using the split() method of the String: First, split the entire string into "line" tokens, where each token represents a row in the final matrix of data. The number of tokens is the number of rows in the 2D array of doubles. Then, you split each line token to extract individual numeric values. The number of tokens is the number of columns in the 2D array of doubles. At this point, you can allocate your double[][] array. All this functionality will go into the class called DataMatrix, which will contain the 2D array of doubles (as a private instance variable), as well as a method for initializing it based on a single String. Once you have your DataMatrix class initializing 2D array of doubles, you will need to write at least five additional methods for DataMatrix: ● ● You can then loop through your tokens and convert each string containing a number - e.g. "1" - into a double value using the static method Double.parse Double(). This double value would then go into your 2D array of doubles at the appropriate location. ● A method that calculates and returns the average value for every row: public double[] rowAverage(); A method that calculates and returns the average value for every column: public double[] columnAverage(); A method that calculates and returns the overall average value for the data: public double[] matrixAverage(); A method that calculates and returns the minimum value in the data: public double minValue(); A method that calculates and returns the maximum value in the data: public double maxValue(); Make sure the above methods return the data, instead of displaying it. In other words, they must have double as the return type, and contain no print statements. It is also recommended that you implement a method for displaying the 2D array on the screen, so you can compare it to the CSV file and verify that your parser works correctly. How you do this is up to you. 2 Implementation Your assignment will consist of the following three classes: CSVReader - provided by me. Contains the code for a reading date from a file. Don't modify it DataMatrix - must be written by you from scratch. It will implement all of the functionality for your data matrix ● Assignment2 - a class with the main() method. I provide you with a skeleton that you must expand. The purpose of this class is to test the DataMatrix class and its methods. Your code will have only one main() method, provided in the Assignment2 class. Do not put main methods anywhere else! Assignment2 takes the name of the CSV file as the common line argument. In the main method of Assignment2, you will need to do the following: Load a CSV file into a String. This is already done in the skeleton file provided for you. Create one DataMatrix object and initialize it using the string you've just read in • After this, use the appropriate methods of the DataMatrix object to calculate and display: You can assume that the CSV file is correctly formatted and every row has the exact same number of values. 3 Evaluation Your code must compile, run, and have all of the above functionality implemented according to the object-oriented programming (OOP) principles covered in class. Any compiler errors will result in the automatic grade of zero (0) for the assignment. Make sure to have ● o The average value for every row o The average value for every column o The overall average value for the data o The minimum value in the data o The maximum value in the data ● Follow submission instruction Correct and nom-missing functionality No Run-time errors No Compiler warnings Good indentation Good variable names Good OOP practices Sufficient comments
Expert Answer:
Answer rating: 100% (QA)
Given the detailed description provided here is an example implementation of the three required classes for the CSV file processing assignment 1 CSVRe... View the full answer
Related Book For
College Algebra With Modeling And Visualization
ISBN: 9780134418049
6th Edition
Authors: Gary Rockswold
Posted Date:
Students also viewed these programming questions
-
In this assignment, you are writing a program that converts common texting abbreviations to English words to allow people like yours truly can understand. For the assignment, you are provided with a...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
Figure 6.6 shows the derivative g'. If g(0) = 0, graph g. Give (x, y)-coordinates of all local maxima and minima. -g'(x)- 2 6. -1 Figure 6.6 5
-
A bowling ball traveling with constant speed hits the pins at the end of a bowling lane 16.5 m long. The bowler hears the sound of the ball hitting the pins 2.80 s after the ball is released from his...
-
Steve Silver, a new client, owns stock in HyTeche, Inc., which recently had an initial public offering. In early 2019, his stock is valued at $8 million. His only other asset is $9 million of cash....
-
A university pumps its water from wells located on campus. The falling water table has caused pumping costs to increase, the quantity of water available to decrease, and the quality of water to...
-
Presented below is the trial balance of Vivaldi Corporation at December 31, 2012. InstructionsPrepare a balance sheet at December 31, 2012, for Vivaldi Corporation. Ignore incometaxes. Credits Debits...
-
Formulate your answer based on the information below. The intensity of care delivered dropped from a budgeted case mix of 0 . 9 0 to an actual case mix of 0 . 8 5 . What dollar effect did this have...
-
Lee, Danny and Sue were childhood friends. They loved horses and dreamed of one day owning a horse who won the huge prize money in the famous annual Melbourne Cup horse race. To fulfill this dream,...
-
PURPOSE OF AN AUDIT The financial statements of Chaos Ltd, a listed European company, show the following amounts on year-end 31 Dec 2015 Revenue 120 Mio Profit before taxation 25 Mio Net assets ...
-
How do microbial growth kinetics, characterized by phases such as lag, exponential, stationary, and death phases, provide insights into the dynamic interplay between microbial physiology,...
-
On May 10, 2016, Oracle stock traded for about $120. All things equal, if Oracle had never had a stock split, what would a share of Oracle have traded for that same day? Round answer to the nearest...
-
A preferred stock pays a semi-annual dividend of $12 per share, with the first dividend paid 6-months from now. If j2 = 10%, how much should a share of this stock be selling for today?
-
What regulatory frameworks govern the research, development, and commercialization of products derived from recombinant DNA technology, and how do they ensure safety, efficacy, and ethical standards...
-
Ellena Furniture has projected sales of its product for the next six months as follows. January 100units February 125 units March 180 units April 170 units May 150 units June 130 units The product...
-
1. Zubin Ltd. had set the transfer price at $20 for the purchase of goods from its U.S. subsidiary. But the IRS audited the transfer price and determined that it should have been using a transfer...
-
Can partitioned join be used for r r.A s? Explain your answer
-
Divide the expression. X -4 4x
-
Determine if S is a function. S = {(-3,7), (-1,7), (3,9), (6, 7), (10,0)}
-
Use the binomial theorem to expand each expression. (2 + 3x)
-
Find the Laplace transform of the function \[y(t)=\alpha \sin ^{2} t+\beta \cos ^{2} t .\]
-
Consider the dynamic system, a mass, spring and damper structure, discussed in Example 2.1 and shown in Figure 2.9. Find the Transfer Function model of the dynamic system, where \(f(t)\) is the input...
-
Consider a system with the following State-Variable Matrix model where \(x_{1}(t)\) and \(x_{2}(t)\) are the state variables, the \(u(t)\) is the input and \(y(t)\) is the output. Find the Transfer...
Study smarter with the SolutionInn App