hi for my programming class we have to write an average calculator program in any langauge we want. I did mine in Java and im fairly new to programming. the problem with my code is how can I improve it to make sure user's incorrect input ruins program. for example if a user types in letters instead of numbers. here is my code.
`import java.util.Scanner;
import java.text.DecimalFormat;
public class Average
{
public static void main(String[]args)
{
int count = 0;
int total = 0;
final int stopValue = 0;
int number;
Scanner scan = new Scanner(System.in);
System.out.println("You can enter numbers here and enter zero to finish");
System.out.print("enter the number: ");
number = scan.nextInt();
while(number != stopValue)
{
total += number;
count++;
System.out.print("enter the number: ");
number = scan.nextInt();
}
if(count !=0 )
{
DecimalFormat twoDP = new DecimalFormat("##.00");
System.out.println("\nThe Average is "+ twoDP.format((double)(total)/count));
}
else
{
System.out.println("\nNo numbers entered");
}
}
}
`