Answer:
public class Main
{
public static void main(String[] args) {
System.out.println(celsiusToFahrenheit(10));
}
public static double celsiusToFahrenheit (double celsius){
double fahrenheit = (9/5.0) * celsius + 32;
return fahrenheit;
}
}
Step-by-step explanation:
Create a method named celsiusToFahrenheit that takes one parameter, celsius
Inside the method:
Convert the celcius to fahrenheit using the given formula. Note that, in the formula 9/5 is integer division. You need to convert it to the double so that the result should not be 0. One solution is converting one of the int to decimal, 9/5 → 9/5.0
Return the fahrenheit
Inside the main method:
Call the celsiusToFahrenheit() with some value and print the result