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

代码:

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);
}
}

结果:

 

 

posted @ 2016-09-06 18:48  胡卫雄  阅读(480)  评论(0编辑  收藏  举报