7-1 sdut-JAVA-Sum Of Numbers
分数 8
全屏浏览
切换布局
作者 马新娟
单位 山东理工大学
You are required to write a Java application program that uses a loop to accept ten numbers from the end user. Your program should display the sum of the 10 numbers entered.
Input Specification:
accept ten numbers from the end user.
Output Specification:
display the sum of the 10 numbers entered.
Sample Input:
12
23
34
45
56
67
78
89
90
0
Sample Output:
Sum of numbers is:494.0
代码长度限制
16 KB
时间限制
400 ms
内存限制
64 MB
栈限制
8192 KB
import java.util.Scanner;
public class Main
{
public static void main(String [] args)
{
Scanner in=new Scanner(System.in);
int i=0;
double[] a=new double[10];
double sum=0;
for(i=0;i<10;i++)
{
a[i]=in.nextDouble();
sum=sum+a[i];
}
System.out.println("Sum of numbers is:"+sum);
}
}
标签:10,Scanner,ten,double,sum,numbers,SDUT,JAVAlab4.1
From: https://blog.csdn.net/2302_80130040/article/details/137049672