import java.util.Scanner;
import java.io.Console;
class WeatherProgram{
private double fahrenheit;
private double celsius;
private double temperature;
private double windSpeed;
private double chill;
private int reply;
private String reply2 = "y";
public static void main(String[]args){
Console c = System.console();
Scanner scan = new Scanner(System.in);
while(reply2.equals("y")){
System.out.println("Welcome to Weather Conversion. Please choose one of the following numbers: "+"\n");
System.out.println("1. Fahrenheit to Celsius");
System.out.println("2. Celsius to Fahrenheit");
System.out.println("3. Windchill");
System.out.println("4. Quit");
System.out.println(" ");
reply = scan.nextInt();
if (reply == 1){
System.out.println("Please input fahrenheit temperature: ");
fahrenheit = scan.nextDouble();
fToC(fahrenheit);
}
if (reply == 2){
System.out.println("Please input celsius temperature: ");
celsius = scan.nextDouble();
cToF(celsius);
}
if (reply == 3){
System.out.println("Please input the temperature in degrees fahrenheit: ");
temperature = scan.nextDouble();
System.out.println("Please input wind speed in MPH: ");
windSpeed = scan.nextDouble();
wcCalc(chill);
}
reply2 = c.readLine("Do you wish to continue Weather Conversion, (y/n)?: ");
}
System.out.println("Thank you");
}
public static void fToC(double f){
// removed the double celcius, as it's already declared in class
celsius = ((f-32)*5/9); // check your "5/9" as that's not going to give you a double answer
if (celsius<1){
System.out.println(f + " Fahrenheit = " + celsius + " Celsius. Temperature is below freezing!");
}
if (celsius>32){
System.out.println(f + " Fahrenheit = " + celsius + " Celsius. It is hot!");
}
else{
System.out.println(f + " Fahrenheit = " + celsius + " Celsius.");
}
}
public static void cToF(double c){
//removed double fahrenheit
fahrenheit = ((c*9/5)+32); // check 9/5 math, fix for double
if (fahrenheit<33){
System.out.println(c + " Celsius = " + fahrenheit + " Fahrenheit. Temperature is below freezing!");
}
if (fahrenheit>90){
System.out.println(c + " Celsius = " + fahrenheit + " Fahrenheit. It is hot!");
}
else{
System.out.println(c + " Celsius = " + fahrenheit + " Fahrenheit.");
}
}
public static void wcCalc(double wc){
//removed all restatements of variables
chill = (35.74 + 0.6215 * temperature + (0.4275 * temperature - 35.75) * Math.pow(windSpeed,0.16));
if (chill<-30){
System.out.println("Windchill = " + wc + " Degrees Fahrenheit. Dangerous Windchill!");
}
else{
System.out.println("Windchill = " + wc + " Degrees Fahrenheit");
}
}
}