首页 > 代码库 > 将摄氏温度转化为华氏温度

将摄氏温度转化为华氏温度

代码:

import javax.swing.*;
public class bb{
public static void main(String[] args){
  String input = JOptionPane.showInputDialog(null,"Enter a degree in Celsius","changeDegree",JOptionPane.QUESTION_MESSAGE);
  double Celsius = Double.parseDouble(input);
  double Fahrenheit = (9.0/5)*Celsius+32;
  String result = Celsius+" Celsius is "+Fahrenheit+" Fahrenheit";
  JOptionPane.showMessageDialog(null,result);
}
}

结果:

技术分享

 

技术分享

 

将摄氏温度转化为华氏温度