Write a Java program that converts Fahrenheit to Celsius. Theformula is: celsius
ID: 3617825 • Letter: W
Question
Write a Java program that converts Fahrenheit to Celsius. Theformula is: celsius = (5 / 9) * (fahrenheit - 32) The program reada Fahrenheit degree in double from the input dialog box thenconverts it to Celsius and displays the result in a message dialogbox. In Java, 5 / 9 is 0, so you need to write 5.0 / 9 to obtainthe correct result. The program should also convert feet intometers. The program prompts the user to enter a number in feet,converts it to meters, and displays the result. One foot is 0.305meters.
Sample Output: Temperature 30.0 Fahrenheit is-1.1111111111111112 in Celsius 40 feet is 12.2 metersÏÏÏ Thanks for using my program
Explanation / Answer
Please One question per post..
import java.util.*; import javax.swing.*;
public class tempConvert { public static void main(String args[]) { String input=JOptionPane.showInputDialog("Enter the FarenheitTemperature: ");
double f=Double.parseDouble(input); double c=5.0/9.0*(f-32);
JOptionPane.showMessageDialog(null,"Temperature in Celsius is: "+c); } } import java.util.*; import javax.swing.*;
public class tempConvert { public static void main(String args[]) { String input=JOptionPane.showInputDialog("Enter the FarenheitTemperature: ");
double f=Double.parseDouble(input); double c=5.0/9.0*(f-32);
JOptionPane.showMessageDialog(null,"Temperature in Celsius is: "+c); } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.