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

题目

下面的程序是用do_while语句计算10的阶乘。请在程序的每条横线处填写一个语句,使程序的功能完整。

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

源程序文件代码清单如下:

public class DoWhileLoop

{

public static void main(________)

{

int n=10;

long result=1;

do

{

_______________

}

______________

System.out.println("10的阶乘为: "+result);

}

}


相似考题
更多“下面的程序是用do_while语句计算10的阶乘。请在程序的每条横线处填写一个语句,使程序的功能完整。 ”相关问题
  • 第1题:

    下面的程序的功能是简单的进行键盘输入测试,请在程序的每条横线处填写一个语句,使程序的功能完整。

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

    ____________________

    public class TestKeyBoardInPut

    {public static void main(String[] args)

    {String yourname=JOptionPane. ____________________ ("What is your name?");

    System.out.println("Hello"+yourname);

    ____________________.exit(0);

    }

    }


    正确答案:import javax.swing.*; showInputDialog System
    import javax.swing.*; showInputDialog System 解析:本题主要考查javax.swing包、showInputDialog()方法。解答的关键是掌握javax.swing包、showInputDialog()方法。在本题中,import javax.swing.*;语句的功能是导入javax.swing包,String yourname=JOptionPane.showInputDialog("What is your name?");语句的功能是从控制台键盘读入字符串并赋值yourname,System.exit(0);语句的功能是退出Java的运行环境回到操作系统环境下。

  • 第2题:

    下面的程序的功能是求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);

    }

    }


    正确答案:i+=2 i%2==0 ++count;
    i+=2 i%2==0 ++count; 解析:本题主要考查for循环语句的用法。在本题中,for(int i=1;i=100;i+=2;)语句是用来控制被求的奇数,i+=2;语句是使循环变量递增2,即所求的奇数,如果该数不为奇数,即if (i%2==0),continue,跳过循环体余下的语句,对for语句的“表达式3”即i+=2求值;如果该数为奇数,用count计数器记录所求奇数的个数。

  • 第3题:

    下面的程序是求字符串的长度及每一个位置上的字符。请在每条横线处填写一条语句,使程序的功能完整。

    注意;请勿改动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);

    }

    }

    }


    正确答案:str.length(); msize; char c=str.charAt(m);
    str.length(); msize; char c=str.charAt(m); 解析:本题主要考查对String数据的操作的基本知识、for循环语句的基本知识。解答本题的关键是熟练掌握对String数据的操作的基本知识、for循环语句的基本知识。在本题中,int size=str,length();语句的功能是获得字符串对象str的长度,for(int m=0;msize;m++)语句中的msize;是for循环语句的判断部分,charc=str,charAt(m);语句的功能是获得字符串中指定位置的字符。

  • 第4题:

    下面的程序的功能是求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);

    }

    }


    正确答案:i+=2 i%2==0 ++count;
    i+=2 i%2==0 ++count; 解析:本题主要考查for循环语句的用法。解答本题的关键是熟练使用for循环语句。在本题中,for(int i=1;i=100;i+=2;)语句是用来控制被求的奇数,i+=2;语句是使循环变量递增2,即所求的奇数,在程序中用到的count计数器是记录所求奇数的个数。

  • 第5题:

    下面是关于字符界面基本输入输出的程序,请在程序的每条横线处填写一个语句,使程序的功能完整。

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

    ______________________

    public class SimpleCharInOut{

    public static void main(String args[]){

    char c=" ";

    System.out.println("Enter a character please: ");

    try{

    ____________________//接受用户键盘输入的字符并保存在变量c中

    }

    catch(________________________e){}

    System.out.println("You've entered character "+c);

    }

    }


    正确答案:import java.io.*; c=(char)System.in.read(); IOException或Exception
    import java.io.*; c=(char)System.in.read(); IOException或Exception 解析:本题主要考查try-catch异常捕获结构。解答本题的关键是熟练掌握异常的捕获知识。在本题中,import java.io.*;语句的功能是导入java.io包,c=(char)System.in.read();语句的功能是从键盘缓冲区获得一个字符数据,并赋给字符变量C,IOExcepfion e声明一个IOExcepfion型对象e。