954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

"." Syntax error?

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);	
			}
		}
    }
}
JSpudMonkey
Newbie Poster
11 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

I Used Eclipse to Run this By the Way

JSpudMonkey
Newbie Poster
11 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

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.

NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
 

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);
JSpudMonkey
Newbie Poster
11 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

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.

NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: