Answer:
import java.util.Scanner;
public class num6 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter the temperature");
double temp = in.nextDouble();
System.out.println("Enter C to convert to celsius or F for fahrenheit");
String con = in.next();
if (con.equalsIgnoreCase("C")) {
double Degrees_C = 5 * (temp - 32) / 9;
System.out.println("The temperature of " + temp + "F in Celcius is" +
" " + Degrees_C);
} else if (con.equalsIgnoreCase("F")) {
//Degrees_F = (9(Degrees_C)/5) + 32)
double Degrees_F = (9 * (temp) / 5) + 32;
System.out.println("The temperature of " + temp + " celcius in Farenheit is" +
" " + Degrees_F);
} else {
System.out.println("Invalid value for conversion");
}
}
}
Explanation:
Use Scanner Class to prompt and receive user input
Use string method equalsIgnoreCase in an if statement to test the conversion to degrees celcius or farenheit
evaluate and output the values based on the equation given in the question