Question: Write a Java program that prompts the user to enter integers one at a time, reads them, and continues to do so until the user

Write a Java program that prompts the user to enter integers one at a time, reads them, and continues to do so until the user enters an integer that is the sum of all previous integers entered. Then stop and output how many integers were entered.

Sample Data #1 Enter int: 2 Enter int: 5 Enter int: 7 You entered 3 ints.

Sample Data #2 Enter int: 1 Enter int: 3 Enter int: 5 Enter int: 20 Enter int: 29 You entered 5 ints.

Sample Data #3 Enter int: 5 Enter int: -1 Enter int: 10 Enter int: 10 Enter int: 25 Enter int: 49 You entered 6 ints.

----------------------------------------------------------------------

public static void main(String [] args) {

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!