I need to do create the following programs, with more than one header. A main he
ID: 3633609 • Letter: I
Question
I need to do create the following programs, with more than one header. A main header, then two or more different headers (public class)Write a Java program that includes a method to convert a temperature from Fahrenheit to Celsius according to the following formula:
C = 5/9 (F-32)
Where F is the Fahrenheit temperature and C is the Celsius temperature.
Your main method will do the following:
prompt the user to input the temperature in Fahrenheit.
Then call the method to convert the temperature into Celsius this method would return the result to the main method.
display the Celsius temperature.
Explanation / Answer
Dear,
Java Code:
import java.io.*;
import java.text.DecimalFormat;
class TemperatureTable
{
public static void main(String args[])
{
double F=0,C;//varibles declartion
//Creating scaner object
input=JOptionPane.showInputDialog("Enter Fahrenheit temperature:");
F=Double.parseDouble(input);
DecimalFormat formatter=new DecimalFormat("#0.00");
System.out.println("Farenheit Celcius");
C = celsius(F);// function call
System.out.println(F+" "+formatter.format(C));
System.exit(0);
}
public static double celsius(double F)
{
double temp;
temp = ((5.0/9.0)*(F-32));
return temp;
}
}
Hope this will help you..