Advertisement
Guest User

Untitled

a guest
Jan 24th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class Esercizio1 {
  5. public static void main(String[] args) {
  6. int[] V;
  7. int y=0;
  8. int somma=0;
  9.  
  10. Scanner input = new Scanner(System.in);
  11. System.out.print("dim");
  12. int dim=input.nextInt();
  13. V= new int[dim];
  14. for(int i=1; i<dim; i++) {
  15. System.out.print("V["+i+"]=");
  16. V[i]=input.nextInt();
  17. if(V[i]%2==0) {
  18. somma+=V[i];
  19. y++;
  20. }
  21.  
  22. }
  23.  
  24. System.out.println(somma/y);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement