Last active
August 29, 2015 13:56
-
-
Save Hulzenga/9143352 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
/** | |
* @param args the command line arguments | |
*/ | |
public static void main(String[] args) { | |
Observation o1 = new Observation(); | |
BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); | |
try { | |
System.out.println("Enter observation date:"); | |
o1.date = in.readLine(); | |
System.out.println("Enter wind speed (mph):"); | |
o1.windSpeed = Integer.parseInt(in.readLine()); | |
System.out.println("Enter temperature in degrees (F):"); | |
o1.temperature = Integer.parseInt(in.readLine()); | |
System.out.println("Observation Date: "); | |
System.out.println(o1.getDate()); | |
System.out.println("WindChill:"); | |
System.out.println(o1.getWindChill()); | |
} catch (IOException e) { | |
//show error text here | |
} | |
} | |
} | |
public class Observation { | |
//set defaults here | |
private String date = "01-01-2000"; | |
private Integer windSpeed = 0; | |
private Integer temperature = 0; | |
//empty constructor uses defaults | |
public Observation() { | |
} | |
//constructor using non default values | |
public Observation(String d, Integer wS, Integer t) { | |
date = d; | |
windSpeed = wS; | |
temperature = t; | |
} | |
/* | |
Getters and Setters below (You can generate these with your IDE | |
*/ | |
public String getDate() { | |
return date; | |
} | |
public void setDate(String date) { | |
this.date = date; | |
} | |
public Integer getWindSpeed() { | |
return windSpeed; | |
} | |
public void setWindSpeed(Integer windSpeed) { | |
this.windSpeed = windSpeed; | |
} | |
public Integer getTemperature() { | |
return temperature; | |
} | |
public void setTemperature(Integer temperature) { | |
this.temperature = temperature; | |
} | |
/* | |
Done with getters and setters | |
*/ | |
public double getWindChill() { | |
double windChill = 35.74 + 0.6215 * temperature - 35.75 * Math.pow(windSpeed, 0.16) + .4275 * t * Math.pow(windSpeed, 0.16); | |
return windChill; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment