import java.util.Scanner;


//Exception in thread "main" java.lang.ArithmeticException: / by zero: 분모가 0일때 오류발생
public class Main{

    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);

        int sum = 0;
        int count = 1;
        int average =0;


        System.out.println("Do you play the game?");
        String endKey=scan.next();

        if(endKey.equals("stop")){
            System.out.println("Program END");
            System.exit(0);
        }


        if(endKey.equals("yes")){
            System.out.println("Enter your number to calculate average");
            while(true){
                int E=scan.nextInt();
                endKey=scan.nextLine();
                if(E<0){
                    System.out.println("System error try again");
                    break;
                }
                else if(endKey.equals("stop")){
                    System.out.println("Program End");
                    average=sum/count;
                    System.out.println(average);
                    break;
                }

                else{
                    sum+=E;
                    count+=1;
                }
            }

        }
    }
}

    

출력:Do you play the game?

입력:yes

출력:Enter your number to calculate average

입력:2 3 4 5 엔터

여기서 멈춰있음 명륜진사갈비마냥 무한으로 깜빡깜빡거림 average안구하고
-----------------

Do you play the game?

yes

Enter your number to calculate average

-1

System error try again
----

Do you play the game?

stop

Program END

-------





내가 생각한 로직

"Do you play the game?" 

Yes

숫자 임의로 입력(개수따로 지정안하고 숫자 인풋한뒤 엔터치면 average로 넘어가게/배열로 써버리면 개수가 자동지정되서 특정 숫자개수 입력하고 엔터하면 딱 average나오는데 이건 배열이 없어서 그건안됨 그래서 엔터를 인식하면 average출력으로 넘어가게 해주고싶음)

엔터

average출력