许多网友都在问Java程序中温度转换代码怎么写,对于初学者来说,这个程序确实有电脑度,下面七达网小编为大家搜集的有关Java温度转换的代码,仅供参考,这个代码感兴趣的朋友可以试一下,希望能够对大家有所帮助。
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class temp extends JFrame implements ActionListener,ItemListener{ JTextField jT1,jT2; JLabel jL1,jL2; JButton jB1, jB2; JRadioButton[] jR=new JRadioButton[2]; ButtonGroup radioGroup; JCheckBox[]jC=new JCheckBox[2]; double x; String y; public temp(){ super("温度转换"); public static void main(String args[]){ temp w1=new temp(); } public void actionPerformed(ActionEvent e){ int x1=Integer.parseInt(jT1.getText()); int x2=Integer.parseInt(jT2.getText()); if(e.getSource()==jR[0]){ jL1.setText("摄氏度="); jL1.setText("华氏度"); double x=(Integer.parseInt(jT1.getText()))*1.8+32; jT2.setText(String.valueOf(x)); } if(e.getSource()==jR[1]){ jL1.setText("华氏度="); jL1.setText("摄氏度"); double x=(Integer.parseInt(jT1.getText()))*1.8+32; jT2.setText(String.valueOf(x)); } double x=(Integer.parseInt(jT1.getText())-32)/1.8; jT2.setText(String.valueOf(x)); } public void itemStateChanged(ItemEvent arg0) { // TODO Auto-generated method stub } }import java.awt.*; import java.awt.event.*; import javax.swing.*; public class temp extends JFrame implements ActionListener,ItemListener{ JTextField jT1,jT2; JLabel jL1,jL2; JButton jB1, jB2; JRadioButton[] jR=new JRadioButton[2]; ButtonGroup radioGroup; JCheckBox[]jC=new JCheckBox[2]; double x; String y; public temp(){ super("温度转换");
本站为大家提供 node.js 安装node.js 教程node.js 下载node.js 视频教程node.js web开发node.js 开发工具node.js mysqlnode.js 爬虫node.js npmnode.js ide
开发环境 / 28.6 MB
开发环境 / 59.4 MB
开发环境 / 25.99 MB
编程工具 / 89.61 MB
开发环境 / 69.27 MB
软件评论
请自觉遵守互联网相关政策法规,评论内容只代表网友观点,与本站立场无关!