您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 畜牧/养殖 > 华南农业大学java实验
生科接班人仅供参考!实验1:课堂publicclassMain{publicstaticvoidmain(String[]args){System.out.println(ThefirstJavaProgram.);}}importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){inta,b;Scannerinput=newScanner(System.in);a=input.nextInt();b=input.nextInt();intc=a+b;System.out.println(c);}}课后:importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){inta,b;Scannerinput=newScanner(System.in);a=input.nextInt();b=input.nextInt();if(ab)System.out.println(a);elseSystem.out.println(b);}}实验2:课堂:publicclassMain{publicstaticvoidmain(String[]args){Strings=C:\\ABC.TXTis\file\;System.out.println(s);}}importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){doublepi=3.14159;doubleradius,area;Scannerinput=newScanner(System.in);radius=input.nextDouble();area=pi*radius*radius;System.out.printf(%.2f,area);}}课后:0,2,1,15.000000,1.000000,1.500000importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){inta,b,c,d;Scannerinput=newScanner(System.in);a=input.nextInt();b=a/100;c=(a%100)/10;d=(a%100)%10;System.out.printf(%d\n%d\n%d\n,d,c,b);}}实验3:课堂:importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){doublea,b,c;Scannerinput=newScanner(System.in);a=input.nextDouble();b=input.nextDouble();c=Math.sqrt(a*a+b*b);if(c1.001&&c0.999){System.out.println(Y);}else{System.out.println(N);}}}importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){inta;Scannerinput=newScanner(System.in);a=input.nextInt();if(a=0&&a10){System.out.println(1);}elseif(a=10&&a100){System.out.println(2);}elseif(a=100&&a1000){System.out.println(3);}elseif(a=1000&&a10000){System.out.println(4);}elseif(a=10000&&a100000){System.out.println(5);}elseif(a=100000&&a1000000){System.out.println(6);}elseif(a=1000000&&a10000000){System.out.println(7);}elseif(a=10000000&&a100000000){System.out.println(8);}else{System.out.println(9);}}}importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){inta,b,c,temp;Scannerinput=newScanner(System.in);a=input.nextInt();b=input.nextInt();c=input.nextInt();if(ab){temp=a;a=b;b=temp;}if(ac){temp=a;a=c;c=temp;}if(bc){temp=b;b=c;c=temp;}System.out.println(a+,+b+,+c);}}课后:importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){inta,b,c,d,e;Scannerinput=newScanner(System.in);a=input.nextInt();b=input.nextInt();c=input.nextInt();d=input.nextInt();e=input.nextInt();if(a%27==0){System.out.println(YES);}else{System.out.println(NO);}if(b%27==0){System.out.println(YES);}else{System.out.println(NO);}if(c%27==0){System.out.println(YES);}else{System.out.println(NO);}if(d%27==0){System.out.println(YES);}else{System.out.println(NO);}if(e%27==0){System.out.println(YES);}else{System.out.println(NO);}}}importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){inta;Scannerinput=newScanner(System.in);a=input.nextInt();if(a0){System.out.println(positive);}elseif(a0){System.out.println(negative);}if(Math.abs(a)%2==0){System.out.println(even);}elseif(Math.abs(a)%2!=0){System.out.println(odd);}}}$line1$input.nextFloat()$line2$input.nextFloat()$line3$result=a+b;break;$line4$result=a-b;break;$line5$result=a*b;break;$line6$result=a/b;break;实验4:课堂:importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){inti=1;intsum=1;intn;Scannerinput=newScanner(System.in);n=input.nextInt();while(i=n){sum=sum*i;i++;}System.out.println(sum);}}importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){inti=1;intsum=0;intn;Scannerinput=newScanner(System.in);n=input.nextInt();inty=2*n-1;while(i=y){sum=sum+i;i=i+2;}System.out.println(sum);}}importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){longa,b,temp;Scannerinput=newScanner(System.in);a=input.nextInt();b=input.nextInt();while(a%b0){temp=a;a=b;b=temp%b;}System.out.println(b);}}课后:importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){intmin=0;Scannersc=newScanner(System.in);for(inti=0;i10;i++){intt;t=sc.nextInt();if(i==0)min=t;min=min=t?min:t;}System.out.println(min);}}publicclassMain{publicstaticvoidmain(String[]args){for(intn=2;n=200;n++){booleanprime=true;for(inti=2;in;i++){if(n%i==0){prime=false;break;}}if(prime)System.out.println(n);}}}importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){intn;Scannerinput=newScanner(System.in);n=input.nextInt();for(inti=1;i=n+1;i++){for(intj=1;j=n+1-i;j++){System.out.printf(%1s,);}for(intk=1;k=2*i-1;k++){System.out.print(*);}System.out.println();}for(inti=n;i0;i--){for(intj=n;ji-1;j--){System.out.printf(%1s,);}for(intk=2*i-1;k0;k--){System.out.print(*);}System.out.println();}}}实验5:课堂:importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){intn;Scannerinput=newScanner(System.in);n=input.nextInt();int[]array=newint[n];int[]list=newint[n];for(inti=0;iarray.length;i++){array[i]=input.nextInt();list=array;}for(intk=0;klist.length;k++){System.out.printf(%d,list[n-k-1]);}}}importjava.util.Scanner;publicclas
本文标题:华南农业大学java实验
链接地址:https://www.777doc.com/doc-7061904 .html