This should load the data provided by the Scanner into your WeatherData class. The data should be loaded one line of text at a time using the Scanner’s nextLine method.

computer science

Description

This should load the data provided by the Scanner into your WeatherData class. The data should be loaded one line of text at a time using the Scanner’s nextLine method. The first line of text should be discarded as it is a header. Each line of text, stored in a String, should be split using the .split(",") method. This will create an array of Strings. The relevant Strings are index 1, which indicates the date for the data on this line, index 2, which will indicate if the day contains multiple days of precipitation (or will be blank if it is just a single day of data), index 3, which indicates a multiple day precipitation total (or will be blank if it is a single day of precipitation), index 4, which indicates the single day precipitation total (or will be blank if the day contains multiple days of precipitation), index 5, which indicates the day’s snowfall total, index 7 which indicates the day’s high temperature (and may be blank if this was not recorded), and index 8 which indicates the day’s low temperature (and may be blank if this was not recorded). All other indexes may be ignored. 


Every index in the split array that is not blank will be surrounded by double quote characters. The substring method may help you remove them. You may assume that each row has a valid date in the form YYYY-MM-DD and that the dates are in chronological order, but there may be missing dates. Temperatures are always whole numbers but precipitation and snowfall may contain decimal points. The Integer.parseInt and Double.parseDouble methods may help you convert the corresponding String to numeric data.

Instruction Files

Related Questions in computer science category