SDUT JAVAlab4.1

简介: SDUT JAVAlab4.1

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);
  }
}


目录
相关文章
|
2月前
sdut 链表7
sdut 链表7
16 0
|
2月前
SDUT 链表9-------7-9 sdut-C语言实验-约瑟夫问题
SDUT 链表9-------7-9 sdut-C语言实验-约瑟夫问题
19 0
|
2月前
7-5 sdut-C语言实验-最少拦截系统
7-5 sdut-C语言实验-最少拦截系统
25 6
|
2月前
|
算法
7-2 sdut-C语言实验-数字三角形问题
7-2 sdut-C语言实验-数字三角形问题
14 1
|
2月前
7-4 sdut-C语言实验-区间覆盖问题
7-4 sdut-C语言实验-区间覆盖问题
22 2
|
2月前
7-2 sdut-C语言实验-删数问题
7-2 sdut-C语言实验-删数问题
18 2
|
2月前
|
机器学习/深度学习 安全
7-3 sdut-C语言实验-小鑫去爬山
7-3 sdut-C语言实验-小鑫去爬山
22 2
|
2月前
sdut 实验3.9---------7-9 sdut-C语言实验-蟠桃记 分数 20
sdut 实验3.9---------7-9 sdut-C语言实验-蟠桃记 分数 20
15 0
|
2月前
sdut 链表10------7-10 sdut-C语言实验-不敢死队问题
sdut 链表10------7-10 sdut-C语言实验-不敢死队问题
15 0
|
2月前
7-8 sdut-C语言实验-装船问题分数
7-8 sdut-C语言实验-装船问题分数
17 0