Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import java.util.Scanner; public class Main { static final int LIMIT = 100; public static void main (String[] arg) { Scanner sc = new Scanner(System.in); int[] num = new int[LIMIT]; int sum = 0, count = 0; double avg = 0; for (int i=0; i<LIMIT; i++) { num[i] = sc.nextInt(); if(num[i] == 0) break; if((num[i]%5) == 0) { count++; sum += num[i]; } } avg = (double)sum/count; System.out.printf("Multiples of 5 : %d\n", count); System.out.printf("sum : %d\n", sum); System.out.printf("avg : %.1f\n", avg); } } | cs |