IN JAVA LANGUAGE PLEASE: Write a Java program that reads temperature data from t
ID: 3665080 • Letter: I
Question
IN JAVA LANGUAGE PLEASE:
Write a Java program that reads temperature data from the user and displays statistical data about those temperatures. The program will begin by asking the user to enter the name of the location of the readings. (Note: the location may contain spaces and commas.) Create an array of ten doubles. Read in temperature values from the user and store them in the array until -999 is entered or ten values have been entered. Use appropriate prompts to request user input. When done reading temperatures, print a report in the exact format shown below. While printing, use the following methods to determine Celsius, high, low, and average temperatures.
Explanation / Answer
import java.util.*;
public class DailyWeatherData
{
public int dayOfMonth;
//Temperature is in Fahrenheit.
public int maxTemperature;
public int minTemperature;
//Precipitation is hundrethds of inches. ex.
public int precipitation;
private ArrayList<String> weatherData;
/**
* Constructor for objects of class DailyWeatherData
public DailyWeatherData(int day, int max,int min, int precip)
{
day = dayOfMonth;
max = maxTemperature;
min = minTemperature;
precip = precipitation;
weatherData = new ArrayList<String>();
}
public void setDayOfMonth(int day){
if(day>=1&&day<=31){
day=dayOfMonth;
}
else{
System.out.println("Value must be between 1 and 31!");
}
}
public void setMaxTemperature(int max){
if(max>=-50&&max<=120){
max=maxTemperature;
}
else{
System.out.println("Value must be between -50 and 120!");
}
}
public void setMinTemperature(int min){
if(min>=-50&&min<=120){
min=minTemperature;
}
else{
System.out.println("Value must be between -50 and 120!");
}
}
public void setPrecipitation(int precip){
}
public int getDayOfMonth(){
return dayOfMonth;
}
public int getMaxTemperature(){
return maxTemperature;
}
public int getMinTemperature(){
return minTemperature;
}
public double getPrecipitation(){
return precipitation/100.0;
}
}