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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started