資源描述:
《云南大學軟件學院Java實驗二》由會員上傳分享,免費在線閱讀,更多相關內(nèi)容在工程資料-天天文庫。
1、姓名:學號:班級:日期:成績:JAVA實驗二一、實驗目的:進一步熟悉JAVA編譯環(huán)境,編譯三個簡單的JAVA程序,熟悉JAVA語言。二、實驗要求:1.WriteJavaprogramcalledAverageNumbers.javatodeterminetheaverageofseveralnumbers?Setthefollowingfiveintegervariables:inti=5int2=7int3=4int4=25int5=13Calculateanddisplaytheaverageofthes
2、enumbersandthesquarerootofaverage.2.WriteatemperatureconversionJavaprogramcalledFarheheitToCentigrade?java?SetavariablecalledtempFarenheit=98.6.CalculatetheCentigradetemp(tempCelcius)byusingtheformulaCentigrade=5/9(Fahrenheit-32)3.WriteaJavapayrollprogramca
3、lledPayroll?javathatdeterminespayandtaxes.Setthefollowingvariables:pay=$25perhourhoursWorked=40CalculategrossPaybymultiplyingpay*hoursWorked.CalculatetaxesWithheldbymultiplyinggrossPay*.15.CalculatenetPaybysubtractingtaxesWithheldfromgrossPay.Displayallvari
4、ables.三.實驗內(nèi)容:1packagelab2;23publicclassAverageNumber{publicstaticvoidmain(String[]args){5inta=5;6intb=7;7intc=4;8intd=25;9inte=13;101112131415161718doubleaveragenumber;doublesum;sum=a+b+c+d+e;averagenumber
5、=sum/5;System.out.printIn(nTheAverageNumberis:n+ave
6、ragenumber);doublesquareroot;squareroot=Math.sqrt(averagenumber);System.out.println("ThesquarerootNumberis:K+squareroot);2.JLMarkers□PropertiesServersfffiDataSourceExplorer國Snippets二Problems?ConsoleAverageNumber("[JavaApplication]CAProgramFiIes
7、Javajreh8.0_77binjavaw.exe(2016年9月22
8、TheAverageNumberis:10.8ThesquarerootNumberis:3.28633534503099721hello.java21AverageNumberjava0FarheheitToCentigradejava卻[1packagelab2;23publicclassFarheheitToCentigrade{4&publicstaticvoidmain(String[]args){5doxibletem
9、pFarenheit=98.6;6doubleCentigrade;Centigrade=5.0/9.0*(tempFarenheit-32);System?out.pzint1n("TheCentigradeis:n+Centigrade);9}10I11}12<>122Markers□Properties顯ServersIBDataSourceExplorer鈿SnippetsProblems貝Console卻^FarheheitToCentigrade[JavaApplicati
10、on]C:ProgramFilesJavajre1.8-0_77binjavaw.exe(2016年9月TheCentigradeis:37.0packagelab2;23publicclassPayroll{567891011121314publicstaticvoidmain(String[]args){doubleperhourpay=25.0;doublehoursWorked=4