ming.java
来自「计算用JAVA语言编写一些小程序,简单计算器,绘图等.用JAVA语言编写银行管理」· Java 代码 · 共 62 行
JAVA
62 行
import javax.swing.JOptionPane;
public class ming{
public static void main( String args[] )
{
int option;
double degree1;
double celsius1;
double fahrenheit1;
String result;
String degree;
String fahrenheit;
String input;
String celsius;
option = 0;
while (option!=-1){
input = JOptionPane.showInputDialog(
" 1 for Fahrenheit to Celsius\n" +
" 2 for Celsius to Fahrenheit\n -1 to quit:" );
option = (int)Double.parseDouble( input );
switch(option){
case 1:
degree =JOptionPane.showInputDialog( "Enter thr degree in Fahrenheit: " );
degree1 = Double.parseDouble( degree );
celsius1 = ( degree1 - 32 ) * 5 / 9d;
result = "The temp in Celsius is " + celsius1;
JOptionPane.showMessageDialog( null, result, "Result",
JOptionPane.INFORMATION_MESSAGE );
break;
case 2:
fahrenheit =JOptionPane.showInputDialog( "Enter thr Fahrenheit in degree: " );
fahrenheit1 = Double.parseDouble( fahrenheit );
celsius1 =fahrenheit1 * 9d/5+32;
result = "The temp in Celsius is " + celsius1;
JOptionPane.showMessageDialog( null, result, "Result",
JOptionPane.INFORMATION_MESSAGE );
break;
//摄氏温度转化为华氏温度的代码
};
} // end while loop
} // end method Main
} // end class Temperature
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?