下面的程序的功能是求1~100的奇数的和及该和的平均值。请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class SumAndAve{public static void main(String args[]){int count = 0, sum = 0, ave= 0;for (int i = 1; i<= 100; ______)if(______)continue;else{______sum=sum+i;}ave= sum/count;System.out.println( "sum="+sum);System.out.println( "ave="+ave);}}

下面的程序的功能是求1~100的奇数的和及该和的平均值。请在程序的每条横线处填写一个语句,使程序的功能完整。

注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。

public class SumAndAve{

public static void main(String args[]){

int count = 0, sum = 0, ave= 0;

for (int i = 1; i<= 100; ______)

if(______)

continue;

else

{

______

sum=sum+i;

}

ave= sum/count;

System.out.println( "sum="+sum);

System.out.println( "ave="+ave);

}

}


相关考题:

最大真约数是指一个数的(除它本身之外)最大约数。下面的程序是求一个数的最大真约数,请在程序的每条横线处填写一个语句,使程序的功能完整(例如:100的最大真约数是50)。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class MaxDiv{public static void main(String args[ ]){int a=100;______________while(i0){if(____________________)_____________________i--;}System. out. print in (a+"的最大真约数为: "+i );}}

接口是抽象方法和常量的集合,是一种特殊的抽象类。下面的程序是对接口的操作,请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。______________MyInterface{public static int NUM=100;public abstract void print();}public class ClassName___________MyInterface{public void print(){System.out.println(NUM);}public static void main(String args[]){__________________________obj .print();}}

下面的程序是用do-while语句计算10的阶乘。请在程序的每条横线处填写1个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容;仅在横线处填入适当的语句。源程序文件代码清单如下:public class DoWhileLoop{public static void main(______){int n=10;long result=1;do{_____;}_____;System.out.println("10的阶乘为:"+result);}}

下面的程序是求菲波那契(Fibonacci)数列的前10项。已知该数列的前两项都为1,即F(1)=1,F(2)=1;而后面各项满足: F(n)=F(n-1)+F(n-2)。请在程序的每条横线处填写一条语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class Fibonacci{public static void main(String args[]){System.out.printtn("Fibonacci is"+" "+"_______________________);}static long fib(int n){if(______________)return 1;elsereturn _________________}}

下面的程序的功能是简单的进行键盘输入测试,请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。____________________public class TestKeyBoardInPut{public static void main(String[] args){String yourname=JOptionPane. ____________________ ("What is your name?");System.out.println("Hello"+yourname);____________________.exit(0);}}

下面的程序的功能是求1~100的奇数的和及该和的平均值。请在程序的每条横线处填写一个语句,程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class SumAndAve{public static void main(String args[ ]){int count=0,sum=0,ave=0;for(int i=1;i<=100;____________________)if(_____________________)continue;else{___________________sum=sum+i;}ave=sum/count;System.out.println("sum="+sum);System.out.println("ave="+ave);}}

下面的程序是用do_while语句计算10的阶乘。请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。源程序文件代码清单如下:public class DoWhileLoop{public static void main(________){int n=10;long result=1;do{_______________}______________System.out.println("10的阶乘为: "+result);}}

下面的程序是求9999以内的“完全数”。所谓完全数是指这样的自然数:它的各个约数(不包括该数自身)之和等于该数自身。如28=1+2+4+7+14就是一个完全数。请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class QuanShu{public static void main(String args[]){for(int n=l;n<9999;n++)if(______________)System.out.println(n);}public static iht divsum(int n){//该方法功能是求一个数的所有约数int s=0;for(int i=l;i<n;i++)if(_________________)__________________return s;}}

下面的程序是求字符串的长度及每一个位置上的字符。请在每条横线处填写一条语句,使程序的功能完整。注意;请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class CharAtOp{public static void main(String args[ ]){String str="abcdef";int size=System.out.println("字符串str的长度为: "+size);for(int m=0;___________________m++){_______________________System.out.println("str中的第"+m+"个字符是: "+c);}}}