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);	
			}
		}
    }
}

Recommended Answers

All 4 Replies

I Used Eclipse to Run this By the Way

Please copy and paste the full text of the error message.
And show the full text of the line where the error occurs.
For example Your posted source line was not ended by a ;

You have lots of syntax errors and misplaced }

I'm surprised your IDE let you type in so many syntax errors.

Scanner cannot be resolved to a type
Syntax error on token ".", delete this token

at HeatIndexCalculator.main(HeatIndex.java:16)

Scanner input = new Scanner(System.in);

You don't show your import statements so I don't know what the compiler can find definitions for.
Run the code thru a compiler.
My compiler gives better error messages than your IDE.

Read the end of my last post.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.