Question: Using the following code, create a mathematical function to pull statistics from a file for the past 7 , 1 4 , and 3 0
Using the following code, create a mathematical function to pull statistics from a file for the past and days. Also in the code, create the file needed to save the data.
import java.util.ArrayList;
import java.util.Scanner;
class WeatherData
protected String date;
protected int highTemperature;
protected int lowTemperature;
protected String weatherCondition;
public WeatherDataString date, int highTemperature, int lowTemperature, String weatherCondition
this.date date;
this.highTemperature highTemperature;
this.lowTemperature lowTemperature;
this.weatherCondition weatherCondition;
class DailyWeatherData extends WeatherData
public DailyWeatherDataString date, int highTemperature, int lowTemperature, String weatherCondition
superdate highTemperature, lowTemperature, weatherCondition;
class WeeklyWeatherData extends WeatherData
private double averageTemperature;
private String predominantWeatherCondition;
public WeeklyWeatherDataString date, int highTemperature, int lowTemperature, String weatherCondition,
double averageTemperature, String predominantWeatherCondition
superdate highTemperature, lowTemperature, weatherCondition;
this.averageTemperature averageTemperature;
this.predominantWeatherCondition predominantWeatherCondition;
class FortnightlyWeatherData extends WeatherData
private int highestTemperature;
private int lowestTemperature;
public FortnightlyWeatherDataString date, int highTemperature, int lowTemperature, String weatherCondition,
int highestTemperature, int lowestTemperature
superdate highTemperature, lowTemperature, weatherCondition;
this.highestTemperature highestTemperature;
this.lowestTemperature lowestTemperature;
class MonthlyWeatherData extends WeatherData
public MonthlyWeatherDataString date, int highTemperature, int lowTemperature, String weatherCondition
superdate highTemperature, lowTemperature, weatherCondition;
class WeatherDataAnalyzer
private ArrayList weatherDataList;
public WeatherDataAnalyzer
weatherDataList new ArrayList;
public void addWeatherDataWeatherData weatherData
weatherDataList.addweatherData;
Placeholder methods for retrieving statistical information
public void showStatsForLastDays
System.out.printlnStatistics for the last days.";
Implement your statistics computation logic here
public void showStatsForLastDays
System.out.printlnStatistics for the last days.";
Implement your statistics computation logic here
public void showStatsForLastDays
System.out.printlnStatistics for the last days.";
Implement your statistics computation logic here
public class Main
public static void mainString args
WeatherDataAnalyzer analyzer new WeatherDataAnalyzer;
Scanner scanner new ScannerSystemin;
while true
System.out.printlnEnter the date YYYYMMDD:;
String date scanner.nextLine;
System.out.printlnEnter the high temperature:";
int highTemp scanner.nextInt;
System.out.printlnEnter the low temperature:";
int lowTemp scanner.nextInt;
scanner.nextLine; consume the newline character
System.out.printlnEnter the weather condition sunny rainy, cloudy, windy:;
String condition scanner.nextLine;
DailyWeatherData dailyData new DailyWeatherDatadate highTemp, lowTemp, condition;
analyzer.addWeatherDatadailyData;
System.out.printlnDo you want to quit? yesno;
String quit scanner.nextLine;
if yesequalsIgnoreCasequit
break;
System.out.printlnWould you like to pull statistics? days or no;
String statsOption scanner.nextLine;
switch statsOption
case :
analyzer.showStatsForLastDays;
break;
case :
analyzer.showStatsForLastDays;
break;
case :
analyzer.showStatsForLastDays;
break;
default:
System.out.printlnContinuing data collection...";
break;
scanner.close;
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
