For the Java code below, you will demonstrate the ability to use and call multiple methods in your program. Using the code below, create the following methods:
1. A method that converts the temperature from Fahrenheit to Celsius. The method should be passed a parameter - Fahrenheit and should return a result - Celsius.
2. A method to output the results of your temperature conversion. The method should be passed 2 parameters - temperature in Fahrenheit and the temperature in Celsius.
Finally, place an edit in your code to ensure that the user only enters a numeric value.
Your output should appear as follows:
Enter the Fahrenheit temperature you want to convert:
212
This converts to 100 Celsius
Do you want to convert another temperature – Y or N?
Y
Enter the Fahrenheit temperature you want to convert:
100
This converts to 37.8 Celsius
Do you want to convert another temperature – Y or N?
N
The program has ended
import java.text.DecimalFormat;import java.util.Scanner;
public class CS1210
{public static void main(String[] args){Scanner input = new Scanner(System.in);DecimalFormat df = new DecimalFormat("#.#");char choice;do{System.out.print("Enter the Fahrenheit temperature you want to convert: ");double fahrenheit = input.nextDouble();double celsius = ((fahrenheit - 32.0) / 1.8);System.out.println("This converts to " + df.format(celsius) + " Celsius");
System.out.println("Do you want to convert another temperature – Y or N?");choice=input.next().charAt(0);}while (choice == 'Y');System.out.println("The program has ended");
}
}