Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine()),
- number;
- double totalGrades = 0, totalCredits = 0;
- for (int i = 0; i < n; i++) {
- number = Integer.parseInt(scanner.nextLine());
- int grade = number % 10;
- double credit = (int) number / 10;
- totalGrades += grade;
- if (grade == 2) {
- credit = 0;
- } else if (grade == 3) {
- credit *= 0.50;
- } else if (grade == 4) {
- credit *= 0.70;
- } else if (grade == 5) {
- credit *= 0.85;
- }
- totalCredits += credit;
- }
- System.out.printf("%.2f\n%.2f\n", totalCredits, totalGrades / n);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement