Hey guys I was working on making a number averaging program and I wanted to insert this function that allows the user to enter the letter "y" to run again and do another computation, however, my program shows the terminated message (I'm using Eclipse) after the first computation, even though I want the user to be able to enter the input. Here is the part of the source code that puzzles me:
public static void main(String[] args)
{
Scanner input= new Scanner(System.in);
System.out.print("This is an averaging program. How many numbers would you like to average together?");
int total=input.nextInt();
int i;
float sum=0;
for(i=0; i<total; i++)
{
System.out.print("Enter your numbers: ");
sum += input.nextFloat();
}
String y;
System.out.print("Your average is: " + sum/total + "\n");
System.out.print("Would you like to do another computation? Type y for yes, or something else for no.");
y=input.nextLine();