Hey guys, i made a program that calculates a heat index for a area. User inputs humidity, tells actualy temeperaute. But when i compile it, it says i havea syntax error at the
Scanner Input = new Scanner(System.in) line? why is that?
public class HeatIndexCalculator {
private static final double c1 = -42..379, c2 = 2.04901523,
c3 = 10.14333127, c4 = -0.22475541;
private static final double c5 = -.00683783, c6 = -.05481717, c7 = .00122874, c8 = .00085282;
private static final double c9 = -.00000199;
public static void main(String[] args){
int temperature;
double humidity , heatIndex;
Scanner input = new Scanner(System.in);
System.out.println("Please enter the current temperature in degree Fahrenheit:");
temperature = input.nextInt();
System.out..println("Please enter the current humidity as a percentage:");
humidity = input.nextInt();
if(temperature >= 80 && humidity >= 40){
heatIndex = calculateHeatIndex(temperature, humidity);
printHeatIndex(temperature, humidity, heatIndex);
}
else{
System.out.println("This calculator is only valid for temperatures 80F or higher and humidity of atleast 40%.");
System.out.println("We apologize for the inconvenience.");
}
}
private static double calculateHeatIndex(int T, double R){
double HI; //HI = c1 + c2T + c3R + c4TR + c5T^2 + c6R^2 + c7T^2*R + c8TR^2 + c9T^2*R^2 //For simplicity and less text: // T = temperature // R = humidity // HI = heatIndex
HI = c1 + c2*T + c3*R + c4*T*R + c5*T*T + c6*R*R + c7*T*T*R + c8*T*R*R + c9*T*T*R*R;
return HI; }
private static void printHeatIndex(
int currentTemp,
double currentHumidity,
double calculatedHeatIndex){
System.out.printf("At a temperature of %dF and a humdity of %.2f percent...\nIt actually feels like: %.2fF", currentTemp, currentHumidity, calculatedHeatIndex);
}
}
}
}