002-004-008

Array Input

Easy

Problem Description

array Input

In this problem, you will create a program that reads an array size and its integer elements using Scanner, then displays all elements and their sum to standard output.

Learning Objective: Understand how to input multiple values into an array using Scanner and process them

Overview

Create a program that first inputs the array size, then inputs elements to store in the array.

Specifications

  1. Input the array size (number of elements) on the first line
  2. Input that many integers separated by spaces on the next line
  3. Output all array elements
  4. Output the sum of the array

Input Format

5
10 20 30 40 50

Output Format

Elements: 10 20 30 40 50
Sum: 150

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up