欢迎来到天天文库
浏览记录
ID:40557565
大小:166.58 KB
页数:2页
时间:2019-08-04
《Java课后答案题》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、同心圆packagebookback;importjava.applet.Applet;importjava.awt.Graphics;publicclassTestAppletextendsApplet{privatestaticfinallongserialVersionUID=1L;publicvoidpaint(Graphicsg){g.drawOval(50,50,100,100);g.drawOval(20,20,160,160);g.drawString("同心",90,105);}}三角形@Java实现packagebookback;publicc
2、lassDrawTri{publicstaticvoidmain(String[]args){for(inti=1;i<4;i++){for(intj=1;j<=4-i;j++){System.out.print("");}for(intx=1;x<=i*2-1;x++){System.out.print("*");}System.out.println();}}}@Applet实现importjava.applet.Applet;importjava.awt.Graphics;publicclassPrintXingAppletextendsApplet{sta
3、ticvoiddraw(intn,Graphicsg){for(inti=0;i4、ring[]args){inta=2;a=6;intb=7,c=8;doubled=3.14;Stringx="hello";System.out.println(a+b+x+c+d);doubler=2;doublev=Sphere(r);System.out.println(v);}publicstaticdoubleSphere(doubler){doublePI=3.141592653;doublev=(4*PI*r*r*r)/3;returnv;}}矩形周长和面积packagebookback;importjava.util.Scanner;public5、classRectangle{publicstaticvoidmain(String[]args){Scannerin=newScanner(System.in);System.out.println("Pleaseinputthelengthoftherectangle:");intl=in.nextInt();System.out.println("Pleaseinputthewidthoftherectangle:");intw=in.nextInt();doublea=area(l,w);doublep=perimeter(l,w);System.out.6、println("Theareaoftherectangleis"+a);System.out.println("Theperimeteroftherectangleis"+p);}publicstaticdoublearea(doublel,doublew){doublea=l*w;returna;}Publicstaticdoubleperimeter(doublel,doublew){doublep=2*(l+w);returnp;}}奇偶数packagebookback;importjava.util.Scanner;publicclassParity{p7、ublicstaticvoidmain(String[]args){Scannerin=newScanner(System.in);System.out.print("Pleaseinputonenumber:");intnum=in.nextInt();System.out.println();if(num%2==0){System.out.println("even");}else{System.out.println("odd");}}}方程的根packagebookback;importjava.util.Scanner;publicclassRootof8、Equat
4、ring[]args){inta=2;a=6;intb=7,c=8;doubled=3.14;Stringx="hello";System.out.println(a+b+x+c+d);doubler=2;doublev=Sphere(r);System.out.println(v);}publicstaticdoubleSphere(doubler){doublePI=3.141592653;doublev=(4*PI*r*r*r)/3;returnv;}}矩形周长和面积packagebookback;importjava.util.Scanner;public
5、classRectangle{publicstaticvoidmain(String[]args){Scannerin=newScanner(System.in);System.out.println("Pleaseinputthelengthoftherectangle:");intl=in.nextInt();System.out.println("Pleaseinputthewidthoftherectangle:");intw=in.nextInt();doublea=area(l,w);doublep=perimeter(l,w);System.out.
6、println("Theareaoftherectangleis"+a);System.out.println("Theperimeteroftherectangleis"+p);}publicstaticdoublearea(doublel,doublew){doublea=l*w;returna;}Publicstaticdoubleperimeter(doublel,doublew){doublep=2*(l+w);returnp;}}奇偶数packagebookback;importjava.util.Scanner;publicclassParity{p
7、ublicstaticvoidmain(String[]args){Scannerin=newScanner(System.in);System.out.print("Pleaseinputonenumber:");intnum=in.nextInt();System.out.println();if(num%2==0){System.out.println("even");}else{System.out.println("odd");}}}方程的根packagebookback;importjava.util.Scanner;publicclassRootof
8、Equat
此文档下载收益归作者所有