Skip to content

Instantly share code, notes, and snippets.

@folivetti
Created March 6, 2017 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save folivetti/f910878940218a5c9dd1a47ebf473ac7 to your computer and use it in GitHub Desktop.
Save folivetti/f910878940218a5c9dd1a47ebf473ac7 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
class Main {
public static void main(String[] args) {
int X,i;
double soma;
Scanner in = new Scanner(System.in);
X = in.nextInt();
soma = 0;
i = 0;
while(X>0){
soma = soma + X;
i = i + 1;
X = in.nextInt();
}
System.out.printf("%.2f\n",soma/i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment