实验1创建、编译和运行Java程序17268计算两个整数的和从键盘输入两个整数,计算并输出两个整数的和。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);}}17269输出两个整数中的较大的值从键盘输入两个整数,判断并输出两个整数中较大的值。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基本数据类型、运算和表达式18135在显示屏上显示指定字符要求编写一个程序,在显示屏上显示如下内容。注:类名必须为Main(大写M)C:\ABC.TXTisfilepublicclassMain{publicstaticvoidmain(String[]args){System.out.print(C:\\ABC.TXTis\file\);}}18136计算圆的面积由键盘输入圆的半径,计算并输出圆的面积,结果保留2位小数。注:类名必须为Main(大写M)importjava.util.Scanner;importjava.text.DecimalFormat;publicclassMain{publicstaticvoidmain(String[]args){doublea,b,c;Scannerinput=newScanner(System.in);a=input.nextDouble();b=3.14159;c=a*a*b;System.out.println(newDecimalFormat(#.##).format(c));}}18138输出三位整数的各位数字从键盘输入一个3位的整数,要求按照:个位、十位和百位的顺序输出三个数字。输出时,每个数字占单独的一行。注:类名必须为Main(M大写)importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){Scannerinput=newScanner(System.in);intcr=input.nextInt();intb,c,d;b=cr/100;c=cr/10%10;d=cr%10;System.out.println(+d);System.out.println(+c);System.out.println(+b);}}实验3选择结构程序设计18139判断点是否在圆上由键盘输入一个点的坐标,要求编程判断这个点是否在单位圆上,点在圆上输出Y,不在圆上输出N。使用小数点后3位精度进行判断。注:类名必须用Main(大写M)importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){Scannerinput=newScanner(System.in);doublex=input.nextDouble();doubley=input.nextDouble();doubledistance=Math.sqrt(x*x+y*y);if(Math.abs(distance-1.0)0.001){System.out.println(Y);}else{System.out.println(N);}}}18140求数的位数由键盘输入一个不多于9位的正整数,判断并输出它是几位数。注:类名必须是Main(大写M)importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){Scannerinput=newScanner(System.in);inta,place;a=input.nextInt();if(a99999999){place=9;}elseif(a9999999){place=8;}elseif(a999999){place=7;}elseif(a99999){place=6;}elseif(a9999){place=5;}elseif(a999){place=4;}elseif(a99){place=3;}elseif(a9){place=2;}else{place=1;}System.out.println(place);}}18141数的排序由键盘输入三个整数a、b、c,按从小到大的顺序输出这三个数。注:类名必须是Main(M大写)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);}}18142数的整除由键盘输入5个整数,逐个判断它们能否被27整除,能的输出“YES”,不能的输出“NO”(注意,输出时,一个判断结果占一行,5个数的判断共占5行)。注:类名必须是Main(大写M)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);}}}18143正负奇偶判断由键盘输入非零整数x,判断该数正负,正数输出positive,负数输出negative,接着判断该数的奇偶性,奇数输出odd,偶数输出even。注:类名必须是Main(大写M)importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){intx;Scannerinput=newScanner(System.in);x=input.nextInt();if(x0){System.out.println(positive);}else{System.out.println(negative);}if(x%2==0){System.out.println(even);}else{System.out.println(odd);}}}18144简单四则运算器下面程序是实现一个简单的四则运算器(输出结果保留2位小数)。输入时依次输入:第1个实数、运算符、第2个实数,程序根据运算符进行运算并输出结果。在程序中的空白处填写恰当的代码,运行通过后在评判系统中提交。importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){floata,b,result;charoperator;Scannerinput=newScanner(System.in);a=input.nextFloat();operator=input.next().charAt(0);b=input.nextFloat();switch(operator){case'+':result=a+b;break;case'-':result=a-b;break;case'*':result=a*b;break;case'/':result=a/b;break;default:System.out.println(error);return;}System.out.printf(%.2f\n,result);}}实验4循环结构程序设计18145计算阶乘输入正整数n,计算n!,结果用长整型数表示(注n!=1*2*3*...*n)注:类名必须是Main(大写M)importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){Scannerinput=newScanner(System.in);intnum=1;intx;x=input.nextInt();for(inti=x;i0;i--){num=num*i;}System.out.println(num);}}18146计算数列和有数列1,3,5,7,9,11,……,现要求由键盘输入n,计算输出该数列的前n项和。注:类名必须是Main(大写M)importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){Scannerinput=newScanner(System.in);intsum=0;intn;n=input.nextInt();for(inti=1;i=n;i++){sum=sum+i*2-1;}System.out.println(sum);}}18147求最大公约数由键盘输入两个正整数m、n(m、n用长整数表示),计算它们的最大公约数。注:类名必须是Main(大写Mimportjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){Scannerinput=newScanner(System.in);intm=input.nextInt();intn=input.nextInt();intmax,min;if(mn){max=m;min=n;}else{min=m;max=n;}intgcd;for(gcd=min;gcd=1;gcd--){if(max%gcd==0&&min%gcd==0){break;}}System.out.println(gcd);}}18148输出最小值从键盘输入十个整数,输出最小值。注:类名必须是Main(大写M)importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]arg