Skip to content
Advertisement

Java program that reads user input until 0 is entered, also makes a few calculations (evens/odds, average, etc.)

This program is meant to take user input until a zero is entered, and then print out information on the integers. It’s also meant to read if the input in even/odd, calculate the sum, find the largest and smallest entered integers, tally the total integers entered, and find the average. It won’t stop when the user enters 0, and it won’t print the “No data entered” line if there’s no input. It also isn’t figuring even numbers properly.

JavaScript

Advertisement

Answer

When reading the first numbers to populate large and small we only need to do that once. And without re-reading the numbers with in.nextInt() because that will eat up the next inputs that are entered, which was probably causing the not terminating at zero error.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement