Many numbers and sum Learn programming Java


Arrays, Structures and Strings


Many numbers and sum


Create a program which asks the user for several numbers (until he enters "end" and displays their sum). When the execution is going to end, it must display all the numbers entered, and the sum again, as follows:

Enter a number: 5
Sum = 5
Enter a number: 3
Sum = 8
Enter a number: end
The numbers are: 5 3
The sum is: 8


import java.util.*;
public class Main
	public static void main()
		float[] numbers = new float[1000];
		String entrada;

		System.out.print("Enter a number: ");
		entrada = new Scanner(;

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.