fork download
  1. import java.lang.Math; // headers MUST be above the first class
  2. import java.util.Scanner;
  3.  
  4. // one class needs to have a main() method
  5. public class Ideaone
  6. {
  7. public static void main(String[] args) {
  8. System.out.println("Enter the scores:");
  9. Scanner scanner = new Scanner(System.in);
  10. int n = scanner.nextInt();
  11. int total = 0;
  12. int count = 0;
  13. while (n != -1) {
  14. total += n;
  15. count++;
  16. n = scanner.nextInt();
  17. }
  18. int calc = (total / count);
  19. System.out.println(calc);
  20. }
  21. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
100
70
80
90
-1
compilation info
Main.java:5: error: class Ideaone is public, should be declared in a file named Ideaone.java
public class Ideaone
       ^
1 error
stdout
Standard output is empty