Butlletí de notes
Submit solution
Points:
10
Time limit:
5.0s
Memory limit:
256M
Author:
Problem type
Allowed languages
C#, Go, Java, Python
Afegeix els camps i mètodes que falten a la classe ReportCard
.
La variable weight
indica el pes de l'activitat en la nota final.
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
class Grade {
String name;
float grade;
float weight;
Grade(String n, float g, float w) {
name = n;
grade = g;
weight = w;
}
}
class ReportCard {
ReportCard(int numGrades){
grades = new Grade[numGrades];
}
}
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
ReportCard reportCard = new ReportCard(n);
for (int i = 0; i < n; i++) {
String assignment = scanner.next();
float grade = scanner.nextFloat();
float weight = scanner.nextFloat();
reportCard.grades[i] = new Grade(assignment, grade, weight);
}
reportCard.calculateAverageGrade();
System.out.format("Average Grade: %.2f%n", reportCard.averageGrade);
}
}
Input Format
-
Constraints
-
Output Format
-
Sample Input 0
2
Projecte 10 50
Examen 0 50
Sample Output 0
Average Grade: 5.00
Sample Input 1
3
Practiques 9 20
Exercicis 8 30
Examen 5 50
Sample Output 1
Average Grade: 6.70
Sample Input 2
5
Projecte 8 30
Practica1 9 10
Practica2 7 10
Practica3 6 10
Examen 5 40
Sample Output 2
Average Grade: 6.60
Sample Input 3
3
Examen1 5 25
Examen2 6.7 25
Examen3 10 50
Sample Output 3
Average Grade: 7.93
Sample Input 4
1
Examen 7.75 100
Sample Output 4
Average Grade: 7.75
Autoria: Gerard Falcó
CC BY-NC-SA 4.0