全文预览

耿祥义张跃平java大学实用教程编程题标准答案

上传者:塑料瓶子 |  格式:doc  |  页数:97 |  大小:221KB

文档介绍
tringargs[])螂{羃doublesum=0,a=1;虿inti=1;袈while(i<=20)薃{螀if(i>=10)螇sum=sum+a;芇i++;芃a=a*i;螁}膀System.out.println("sum="+sum);蚇}肄}袃8.芈第四章作业题肆1.螄classDengCha{蚀intstart,d;蚁DengCha(){薅}薄DengCha(intstart,intd){螂this.start=start;蝿this.d=d;羅}芅voidsetStart(ints){螃start=s;袇}蚈voidsetD(intd){肅this.d=d;薀}芀intgetSum(intn){肇intsum=0,i=1;螅while(i<=n){蚂sum=sum+start;莈start=start+d;蒇i++;节}蚃returnsum;螁}羆}lassZuoYe4_1蒀{衿publicstaticvoidmain(Stringargs[])莆{螃DengChashulie=newDengCha(2,3);薂System.out.println(shulie.getSum(100));羇shulie.setStart(10);螅shulie.setD(5);蒃System.out.println(shulie.getSum(9));薃}莀}芄芃2.莁classLetter{蒈publicvoidprintLetter(){袈for(charc='a';c<='z';c++)羄System.out.print(""+c);蒂}螀}lassZuoYe4_2蚄{艿publicstaticvoidmain(Stringargs[])罿{螆Letterp=newLetter();蒄p.printLetter();莁}肇}膆3.膅classSquareEquation{

收藏

分享

举报
下载此文档