欢迎来到天天文库
浏览记录
ID:51190211
大小:86.00 KB
页数:4页
时间:2020-03-20
《java基础语言课后题答案.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、1.publicclassExercisel_2{publicstaticvoidmain(String[]args){System.out.println「WelcometoJava1');System.out.println(MWelcometoJava");System.out.println(nWelcometoJava11);System.out.println(HWelcometoJava11);System.out.println「WelcometoJava");}}2.publicclas
2、sExercise1_4{publicstaticvoidmain(String[]args){System.out.pnntln(HaaA2aA3n);System.out.printlnC'l11H);System.out.pnntln(n248“);System.out.printl927”);System.out.println「41664“);}}3.publicclassExercisel_4{publicstaticvoidmain(String[]args){System.out.prin
3、tln「aaA2aA3");System.out.println(Hl11H);System.out.println("248“);System.out.println「3927”);System.out.println「41664“);}}4.publicclassExercisel_6{publicstaticvoidmain(String[]args){System.out.println(l+2+3+4+5+6+7+8+9);}}5.publicclassExercisel_8{publicsta
4、ticvoidmain(String[]args){//DisplayareaSystem.out.println(5.5*5.5*3.14159);//DisplayperimeterSystem.out.println(2*5.5*3.14159);}}6.importjavax.swingJOptionPane;publicclassExercise2_lWithDialogBox{//Mainmethodpublicstaticvoidmain(String[]args){//Enteratemp
5、eraturinFahrenheitStringcelsiusString=JOptionPane.showlnputDialog(null,HEnteratemperatureinCelsius:1',HExercise2_lInput",JOptionPane.QUESTION_MESSAGE);//ConvertstringtodoubledoubleCelsius=Double.parseDouble(celsiusString);//ConvertittoCelsiusdoublefahrenh
6、eit=(9.0/5)*Celsius+32;//DisplaytheresultJOptionPane.showMessageDialog(null,HThetemperatureisH+fahrenheit+”inFahrenheit");}}7.importjava.util.Seanner;publicclassExercise2_2{publicstaticvoidmain(String[]args){Seannerinput=newSeanner(System.in);//Enterradiu
7、softhecylinderSystem.out.print(HEnterradiusofthecylinder:H);doubleradius=input.nextDouble();//EnterlengthofthecylinderSystem.out.print(nEnterlengthofthecylinder:H);doublelength=input.nextDouble();doublevolume=radius*radius*3.14159*length;System.out.printl
8、n('ThevolumeofthecylinderisH+volume);}}8.publicclassExercise2_4{publicstaticvoidmain(String[]args){//Prompttheinputjava.util.Seannerinput=newjava.util.Seanner(System.in);System.out.print(”Enteranumberinpounds:H);dou
此文档下载收益归作者所有