Missing Code:
import java.util.Scanner;
public class CelsiusToFahrenheit {
// FINISH: Define celsiusToFahrenheit method here
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
double tempF = 0.0;
double tempC = 0.0;
System.out.println("Enter temperature in Celsius: ");
tempC = scnr.nextDouble();
// FINISH
System.out.print("Fahrenheit: ");
System.out.println(tempF);
return;
}
}
Answer:
Replace // FINISH: Define celsiusToFahrenheit method here
with
public static double celsiusToFahrenheit(double tempC){
double tempF = (tempC * 9/5) + 32;
return tempF;
}
Replace // FINISH
with
tempF = celsiusToFahrenheit(tempC);
Explanation:
The first addition to the program:
This line defines the method
public static double celsiusToFahrenheit(double tempC){
This line calculates the Fahrenheit equivalent of the temperature in Celsius
double tempF = (tempC * 9/5) + 32;
This line returns the temperature in Fahrenheit back to the main method
return tempF;
}
The second addition to the program:
This line gets the returned tempF from the celsiusToFahrenheit module
tempF = celsiusToFahrenheit(tempC);
See attachment for complete program