Demo entry 6643775

编写一个Java应用程序,用户从键盘只能输入整数,程序输出这些整数的乘积。

   

Submitted by anonymous on Sep 29, 2017 at 04:46
Language: Java. Code size: 488 Bytes.

//编写一个Java应用程序,用户从键盘只能输入整数,程序输出这些整数的乘积。
import java.util.Scanner;
public class D01
{
    public static void main (String args[])
    {
        System.out.print("请输入需要计算乘积的整数(输入任意非整数结束应用):\n");
        Scanner reader=new Scanner(System.in);
        int sum=00;
        int m = 00;
        while(reader.hasNextInt())
        {
            int x=reader.nextInt();
            m++;
            sum+=x;
        }
        System.out.printf("输入的%d个整数的乘积为%d\n",m,sum);
    }
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).