جافا......المشكلة الاولي + الحل

1- Write a java a program that converst Fahrenheit to celsuis. The formula for the conversiona is
Celsius = (5/9) * (fahrenheit - 32)
Solution:
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] args) {
//Get input string from user, then convert to float
float f=Float.parseFloat(JOptionPane.showInputDialog("please enter the Fahrenheit value"));
//Write conversion equation
float c=(5*1.0f/9) * (f - 32);

//Display result
JOptionPane.showMessageDialog(null, "the Celsius value is="+c);
}
}

0 comments: