help me please the code works correctly but the site does not compile

Back to Problem Solutions forum

Popovich Arseny Igorevich     2020-05-28 17:24:58

package com.company; import java.util.ArrayList; import java.util.Scanner;

public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int countOperation = 0;

    System.out.print("Введите количество операций: ");
    countOperation = in.nextInt();
    for (int i = 0; i < countOperation; i++) {
        Solution();
    }
}
public static void Solution() {
    ArrayList<Integer> list = new ArrayList<>();
    int countOperation = 0;
    boolean point = false;
    int inputData = 0;
    int averge = 0;
    int sum = 0;

    Scanner in = new Scanner(System.in);
    System.out.println("Введите значения: ");

    while (point == false) {
        list.add(inputData = in.nextInt());
        if (inputData == 0) {
            list.remove(list.size()-1);
            for (int i = 0; i < list.size(); i++) {
                sum += list.get(i);
              averge = sum / list.size();
            }
            System.out.println(averge);
            point = true;
        }
    }
}

}

Rodion (admin)     2020-05-31 06:19:08
User avatar

Hi Friend!

Not sure what you may mean by "not compile"... The "sandbox" used by the site may not work sometimes, but anyway you should be able to submit answer calculated with running code locally.

BTW generally you don't want spare outputs in the code as they will be included along with answer:

 System.out.println("Введите значения: ");
Please login and solve 5 problems to be able to post at forum