I have this code and have it almost complete. all I need to do is have it start
back where the non integer was entered instead of the integer. for example if you are on the 3rd integer entered and I entered "F" instead, it will prompt you to enter an integer and the move to number 4 instead of starting all over again. Can anyone please help.
import java.io.File;
import java.util.Scanner;
public class ParseInt {
public static void main(String[] args) {
int num1 =0, num2=0, num3=0, num4=0, num5=0, num6=0, num7=0, num8=0, num9=0, num10=0;
int x = 10, count;
System.out.println("Enter 1st of 10 numbers to finnd the Average ");
What you need is an array of integers to hold the user input once it has been validated (i.e. converted to integers as you are doing with Integer.parseInt), a for loop to populate the array, and inside that for loop another while loop to validate the input and not move on to the next input until a valid input is received. Your average calculation at the end then needs to sum all the integers in the array and divide by the number of digits.
Bookmarks