欢迎来到天天文库
浏览记录
ID:8546827
大小:18.54 KB
页数:12页
时间:2018-04-01
《accp6.0java1第九章上机练习(accp6.0java1 ninth chapter practice on the computer)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、accp6.0java1第九章上机练习(Accp6.0java1ninthchapterpracticeonthecomputer)Exercise1:maintainanorderlylistofbooksImportjava.util.Scanner;/***insertbooksinsequence*/PublicclassBook{Publicstaticvoidmain(String[]args){String[]books=newString[]{,"Computer","Hibernate","Java","Struts"};String[
2、]newBooks=newString[books.length+1];//thebookintothearrayString="book";//keepabookfromtheusernameIntindex=books.length;//savenewinsertionposition//outputintotheresultsbeforeSystem.out.print("arraybeforeinsertion:");For(inti=0;I3、opyinthebooksarrayelementstothearrayofnewBooksFor(inti=0;I4、reToIgnoreCase(Book)>0){Index=i;Break;}}For(inti=newBooks.length-1;I>index;i--){NewBooks[i]=newBooks[i-1];theelementbeginningwiththe//indexsubscriptmovesonepositionlater}NewBooks[index]=book;//newelementsintheindexposition//outputafterinsertionoftheresultsSystem.out.print(inserta5、rray:"");For(inti=0;I6、tsum=0.0F;//thesumofscoresFloataverage=0.0F;//averagevalue//loopinputstudentachievementScannerinput=newScanner(System.in);System.out.println("pleaseentertheresultsof4participants");For(inti=0;I7、xtInt();Sum=sum+score[i];//cumulativescore}Average=sum/score.length;//averageSystem.out.println(theaveragescoreofparticipantsis:+average);}}Exercise3:enterthenumberoflines,printrighttriangleImportjava.util.Scanner;/***enterthenumberoflinesandprintrighttriangles*/PublicclassRTriAn8、gle{Publicstaticvoidmain(String[]args){I
3、opyinthebooksarrayelementstothearrayofnewBooksFor(inti=0;I4、reToIgnoreCase(Book)>0){Index=i;Break;}}For(inti=newBooks.length-1;I>index;i--){NewBooks[i]=newBooks[i-1];theelementbeginningwiththe//indexsubscriptmovesonepositionlater}NewBooks[index]=book;//newelementsintheindexposition//outputafterinsertionoftheresultsSystem.out.print(inserta5、rray:"");For(inti=0;I6、tsum=0.0F;//thesumofscoresFloataverage=0.0F;//averagevalue//loopinputstudentachievementScannerinput=newScanner(System.in);System.out.println("pleaseentertheresultsof4participants");For(inti=0;I7、xtInt();Sum=sum+score[i];//cumulativescore}Average=sum/score.length;//averageSystem.out.println(theaveragescoreofparticipantsis:+average);}}Exercise3:enterthenumberoflines,printrighttriangleImportjava.util.Scanner;/***enterthenumberoflinesandprintrighttriangles*/PublicclassRTriAn8、gle{Publicstaticvoidmain(String[]args){I
4、reToIgnoreCase(Book)>0){Index=i;Break;}}For(inti=newBooks.length-1;I>index;i--){NewBooks[i]=newBooks[i-1];theelementbeginningwiththe//indexsubscriptmovesonepositionlater}NewBooks[index]=book;//newelementsintheindexposition//outputafterinsertionoftheresultsSystem.out.print(inserta
5、rray:"");For(inti=0;I6、tsum=0.0F;//thesumofscoresFloataverage=0.0F;//averagevalue//loopinputstudentachievementScannerinput=newScanner(System.in);System.out.println("pleaseentertheresultsof4participants");For(inti=0;I7、xtInt();Sum=sum+score[i];//cumulativescore}Average=sum/score.length;//averageSystem.out.println(theaveragescoreofparticipantsis:+average);}}Exercise3:enterthenumberoflines,printrighttriangleImportjava.util.Scanner;/***enterthenumberoflinesandprintrighttriangles*/PublicclassRTriAn8、gle{Publicstaticvoidmain(String[]args){I
6、tsum=0.0F;//thesumofscoresFloataverage=0.0F;//averagevalue//loopinputstudentachievementScannerinput=newScanner(System.in);System.out.println("pleaseentertheresultsof4participants");For(inti=0;I7、xtInt();Sum=sum+score[i];//cumulativescore}Average=sum/score.length;//averageSystem.out.println(theaveragescoreofparticipantsis:+average);}}Exercise3:enterthenumberoflines,printrighttriangleImportjava.util.Scanner;/***enterthenumberoflinesandprintrighttriangles*/PublicclassRTriAn8、gle{Publicstaticvoidmain(String[]args){I
7、xtInt();Sum=sum+score[i];//cumulativescore}Average=sum/score.length;//averageSystem.out.println(theaveragescoreofparticipantsis:+average);}}Exercise3:enterthenumberoflines,printrighttriangleImportjava.util.Scanner;/***enterthenumberoflinesandprintrighttriangles*/PublicclassRTriAn
8、gle{Publicstaticvoidmain(String[]args){I
此文档下载收益归作者所有