Sherry,
Herebelow is the correct code :
Change "double f2c(double fahr)" into "static double f2c(double fahr)"
{
return (fahr - 32) * 5 / 9;
}
Explanation :
1.Since you call the method f2c with no reference to any object then this method is linked directly to the Class ... Therefore it must be declared 'static' ...
2. If the static method f2c were declared in another class (ex. Public class Converter(){ ...) then the call to the method in the main method would be written like that :
double celcius = Converter.f2c(fahrenheit);
since f2c is declared 'static' it can be used without instantiating the class Converter ...
Cool ?
Last advice : Get Eclipse as an
IDE for your developement ... it is able to detect that kind of mistake automatically !