欢迎来到天天文库
浏览记录
ID:950556
大小:37.19 KB
页数:0页
时间:2017-10-06
《java语言程序设计基础篇%28英文8版%29课后习题答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、publicclassExercise1_2{publicstaticvoidmain(String[]args){System.out.println("WelcometoJava");System.out.println("WelcometoJava");System.out.println("WelcometoJava");System.out.println("WelcometoJava");System.out.println("WelcometoJava");}}publicclassExercise1
2、_4{publicstaticvoidmain(String[]args){System.out.println("aa^2a^3");System.out.println("111");System.out.println("248");System.out.println("3927");System.out.println("41664");}}publicclassExercise1_6{publicstaticvoidmain(String[]args){System.out.println(1+2+3+
3、4+5+6+7+8+9);}}publicclassExercise1_8{publicstaticvoidmain(String[]args){//DisplayareaSystem.out.println(5.5*5.5*3.14159);//DisplayperimeterSystem.out.println(2*5.5*3.14159);}}importjavax.swing.JOptionPane;publicclassExercise2_1WithDialogBox{//Mainmethodpublic
4、staticvoidmain(String[]args){//EnteratemperaturinFahrenheitStringcelsiusString=JOptionPane.showInputDialog(null,"EnteratemperatureinCelsius:","Exercise2_1Input",JOptionPane.QUESTION_MESSAGE);//Convertstringtodoubledoublecelsius=Double.parseDouble(celsiusString
5、);//ConvertittoCelsiusdoublefahrenheit=(9.0/5)*celsius+32;//DisplaytheresultJOptionPane.showMessageDialog(null,"Thetemperatureis"+fahrenheit+"inFahrenheit");}}importjava.util.Scanner;publicclassExercise2_2{publicstaticvoidmain(String[]args){Scannerinput=newSca
6、nner(System.in);//EnterradiusofthecylinderSystem.out.print("Enterradiusofthecylinder:");doubleradius=input.nextDouble();//EnterlengthofthecylinderSystem.out.print("Enterlengthofthecylinder:");doublelength=input.nextDouble();doublevolume=radius*radius*3.14159*l
7、ength;System.out.println("Thevolumeofthecylinderis"+volume);}}publicclassExercise2_4{publicstaticvoidmain(String[]args){//Prompttheinputjava.util.Scannerinput=newjava.util.Scanner(System.in);System.out.print("Enteranumberinpounds:");doublepounds=input.nextDoub
8、le();doublekilograms=pounds*0.454;System.out.println(pounds+"poundsis"+kilograms+"kilograms");}}//Exercise2_6.java:Summarizealldigitsinaninteger<1000publicclassExercise2_6{//Mainme
此文档下载收益归作者所有