Question: Company has hired you to program a Java program that will load temperature data into an array ( s ) from a comma - delimited
Company has hired you to program a Java program that will load temperature data into an arrays from a commadelimited text data file in order to perform data analysis and reporting. The sample text file containing all the data and a list of required calculations and analysis is included below. A commadelimited text file separates each record with a return and each value within that record is separated by a comma...this means that the comma will not appear within any of the data itself. The program will ask the user for the name of the text file to be loaded and is located within the program directory. The program then will analyze the dataset and automatically identify or calculate values identified in the specifications below. The results will be outputted to the screen for the user with meaningful labels.
You must prompt the user to enter in the name of the data text file that will be opened, loaded, and processed be sure to tell the user if they need to include the file extension or not
You can load the data into the program with multiple individual arrays or a single D array if using multiple individual arrays be sure to pay attention to keep the record indexes consistent and the same across each array
Each record or day within the data file will be on its own line
Each record will contain the daily high temperature and the daily low temperature for a single day separated by a comma
The data for each record will appear in the file in the following format: high temp, low temp
The records within the text files are sorted in ascending order...which means day s data will appear at the top of the text data file and count down from there
After the data has been loaded within the relevant array or arrays the program must determine and calculate
The average of all the daily high temperatures
The average of all the daily low temperatures
The range of the average daily high and daily low temperatures subtract the average of all the daily low temperatures from the the average of all the daily high temperatures...the values calculated for the previous two bullets
The day record number with the greatest daily high temperature for the data set
The day record number with the lowest daily low temperature for the data set
Output all values from the last bulleted section to the screen with meaningful labels
Test Data File that contains days worth of values: TempData.txt
Hint: Do not forget to close down the text file BEFORE you exit the program
Hint : Remember we can use a loop and the hasNext method for file lO that will return a true if there is another row of data or a false if the end of the file is reached
Hint : Since each record contains value you will need load the entire line into a String temporarily so that you can divide and then convert parse the individual pieces of data into the appropriate data type to use for the logic comparisons and calculations required.
Hint : You can use the indexOf String method to find the index position remember this is based of a given character within the value contained in a String. Therefore, if we have a String properly defined and instantiated call strName we could use the following code to find the index position of a comma:
int commalndex strName.indexOf;
System.out.printlnFirst occurrence of a comma with strName String"
is at index position: commalndex;
request: can you write a code for this in java using indexof string method sub string method and also the text file is just temperatures on each line, lines separated by a comma.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
