欢迎来到天天文库
浏览记录
ID:37845091
大小:451.00 KB
页数:24页
时间:2019-06-01
《JAVA基础实验》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、TheFirstExperiment—JavaprogrammingbasicQ1.Install,configureandtestJDK,thenoutput“helloworld”inthecommandwindow.Install,configureandtestJDKfollowthesteponthePPT.WriteasimpleJavasourcecode,compile,interpretandrunit.Typejavactest.javaincommandline.Typejavatestt
2、oseetheresult.ThisprocessiscalledasInterpretingandrunning.Q2.InstallanduseEclipsetooutput“helloworld”.Q3.OutputyourNameandStudentIDNumber.Thisexperimentjustneedmetomakealittlechangeonthesecondone.publicclasstestb{publicstaticvoidmain(String[]args){System.out
3、.println("王梦迪1341906103");}}Q4.InputfourintitemsnamedAge,Math,EnglishandHistoryfromyourkeyboard,giveapromptifanyitem’sinputisnotcorrect.ThatmademeknowsomethingabouttheoperationofoutputinJava.packagejava_input;importjava.util.Scanner;publicclassScannerTest{pu
4、blicstaticvoidmain(String[]args){Scannersc=newScanner(System.in);System.out.println("请输入年龄、数学、英语和历史成绩:");intage=sc.nextInt();intmath=sc.nextInt();intenglish=sc.nextInt();inthistory=sc.nextInt();sc.close();System.out.println("年龄:"+age);System.out.println("数学:
5、"+math);System.out.println("英语:"+english);System.out.println("历史:"+history);}}packagejava_input;importjava.util.InputMismatchException;importjava.util.Scanner;publicclassScannerException{publicstaticvoidmain(String[]args){Scannersc=newScanner(System.in);doub
6、le[]A=newdouble[5];for(inti=0;i7、++产生的下标移位}}sc.close();for(doublei:A)System.out.println(i+"");}}Fig.4.1Fig.4.2Q5.ReadArraysUtil.javacarefully,addthepropercommentsintheprogram,andfinallyanalyzetheresultwithyourownwords.Ihavelearnedsomeoperationsonarray.packagejava_ArraysUtil;importjava.util.8、Arrays;importjava.util.Scanner;publicclassArraysUtil{publicstaticvoidmain(String[]args){double[]X=newdouble[5];System.out.println("pleaseinputthenumbers:");Scannersc=newScanner(System.in);for(in
7、++产生的下标移位}}sc.close();for(doublei:A)System.out.println(i+"");}}Fig.4.1Fig.4.2Q5.ReadArraysUtil.javacarefully,addthepropercommentsintheprogram,andfinallyanalyzetheresultwithyourownwords.Ihavelearnedsomeoperationsonarray.packagejava_ArraysUtil;importjava.util.
8、Arrays;importjava.util.Scanner;publicclassArraysUtil{publicstaticvoidmain(String[]args){double[]X=newdouble[5];System.out.println("pleaseinputthenumbers:");Scannersc=newScanner(System.in);for(in
此文档下载收益归作者所有