Your issue is that you are not returning either in an else
or at the very end.
Also, please adhere to the Java naming conventions.
public class Quiz {
public static String calculateCelsius(double fahrenheit) {
double celcius = 5.0 / 9.0 * (fahrenheit - 32);
if (celcius > 30)
return "hot";
else if (celcius < 10) // I think you want to compare celsius, not 1
return "cold";
else
return "acceptable"; // You need an else,
// ...or you need to return at the very end.
// return "acceptable";
}
public static void main(String[] args) {
System.out.println(calculateCelsius(70.0)); // acceptable
System.out.println(calculateCelsius(14.5)); // cold
}
}
I would break this into two separate functions: one that converts temperature, and another that takes the converted temperature and priduces a string.
public class Quiz {
public static double calculateCelsius(double fahrenheit) {
return 5.0 / 9.0 * (fahrenheit - 32);
}
public static String determineClimate(double temperatureInCelcius) {
if (temperatureInCelcius > 30)
return "hot";
else if (temperatureInCelcius < 10) // I think you want to compare celsius, not 1
return "cold";
else
return "acceptable"; // You need an else,
// ...or you need to return at the very end.
// return "acceptable";
}
public static void main(String[] args) {
System.out.println(determineClimate(calculateCelsius(70.0))); // acceptable
System.out.println(determineClimate(calculateCelsius(14.5))); // cold
}
}