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 30 31 32 33 34 35 36 37 38 39 40
| package cn.ruhe.chapter01;
import java.util.Scanner;
public class Demo02 {
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] a = new int[n]; int[] b = new int[n]; int credit = 0; int point = 0; for (int i = 0; i < n; i++) { a[i] = scanner.nextInt(); b[i] = scanner.nextInt(); credit += a[i]; if (b[i] >= 60){ point += (b[i] - 50)/10*a[i]; } } System.out.println(String.format("%.1f",point*1.00/credit)); } }
|