JAVA实现温度转换:摄氏度转华氏度

(JAVA)编程实现:从键盘输入摄氏温度,求对应的华氏温度值。

importjava.util.scanner; publiClasStest {scannercin = newscanner(system.in); publicVoidConvert(){while(true){system.out.println(“插入温度值celius”); intc = cin.nextint(); inth = C*9 /5 +3 2 ; system.out.println(“转换后的fahrenh是:”+h);}}}}} publicStaticVoidMain(StringArgs []){newTest()。
convert();}}我的程序可以无限期地计算。
如果您不想要无限的周期,那么时间会被时间注意到

编程题:已知两种温度的换算公式C=(5/9)(F-32),试编写一个程序输入华氏度F,输出摄氏度。

使用python的方法是:val =输入(“请在[“ C”,“ C”,“ C”]中使用温度标记(例如:3 2 c)”)ifval [-1 ]:f = 1 .8 *float(val -1 ])-3 2 ) - 3 2 ) - 3 2 )/1 .8 print(“更改的温度为:%.2 fc”%c)print:%c) (){floatf,c; printf(“请输入您需要更改的华氏温度:”); scanf(“%f”,&f); C =(F-3 2 )*5 /9 .0; publicClassPrinttable {publicStaticVomen(StringArgs []){int [int [] Fahrenheit = {0,2 0,4 0,6 0,8 0,1 00,1 2 0,1 2 0,1 4 0,​​1 4 0,​​1 6 0,1 8 0,2 2 0,2 2 0,2 2 0,2 2 0,2 4 0,2 4 0,2 4 0,2 6 0,2 6 0,2 8 0,3 00};  int [] centigrade = newint [5 0];             for(int = 0; i

求大神帮忙编个JAVA的GUI程序,将摄氏温度和华氏温度互相转换,十分感谢!

导入java.awt.eventqueue;导入javax.swing.jframe;导入javax.swing.jbutton;导入Java.awt.event.ActionListenner;导入java.awt.eve nt.azionevent;导入javax.swing.jlabel;导入java.awt.font;导入Java.awt.Color;导入javax.swing.jtextfield;公共类别为{private Frame Jframe;/***启动应用程序。
 */public static void main(string [] args){eventqueue.invokeLater(new runnable(){public void run(){try {a window = new a(); window a(); window.frame.setvisible(true);} catch(exception e)框架的。
 */int count = 0;私人jtextfield txt1 ;私人jtextfield txt2 ;私人标签Jlabel;私人jlabel label_1 ; private void initialize(){frame = new jframe(); frame.settitle(“温度转换”); frame.getContentpa ne()。
setfont(new font(“中国kaiyi”,font.plain,1 8 ));框架。
frame.setDefaultClosePoration(jframe.exit_on_close); frame.getConcontents()。
setLayout(null); label_1 = new Jlabel(“ \ u5 3 4 e \ u6 c0f \ u6 e2 9 \ u5 ea6 :”); label = new Jlabel(“ \ u6 4 4 4 \ u6 c0f \ u6 e2 9 \ u5 ea6 ”); l abel.setfont(new font(“宋体”,font.plain,1 4 )); label.setForeground(color.black); setbounds(2 2 、2 0、7 7 、2 9 ); frame.getConcontents()。
添加(标签); txt1 = new jtextfield(); txt1 .setbounds(1 1 1 ,2 4 ,6 6 ,2 1 ); frame.getConcontents()。
添加(txt1 ); txt1 .setColumns(1 0); jbutton button = new jbutton(“ >>”); button.AddadationListener(new ActionListenner(){public void actionPerpered(action Vent e){double d = double.valueof(txt1 getText()); d = d = d = d*1 .8 +3 2 ; txt2 .setext ext2 .setext(d+“}) (){pu Blue void actionperformed(Action Vent e){double d = double.valueof(txt2 .getText()); font.plain,1 4 )); (label_1 );}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} _