やあみんな私は数平均化プログラムの作成に取り組んでいて、ユーザーが文字「y」を入力して再度実行して別の計算を実行できるようにするこの関数を挿入したかったのですが、私のプログラムは終了メッセージを表示します(私は使用していますEclipse) 最初の計算の後、ユーザーが入力できるようにしたいのですが。これが私を困惑させるソースコードの部分です:
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();