Repository navigation
Expand file tree
/
Copy pathQ8.java
More file actions
58 lines (41 loc) · 1.39 KB
/
Copy pathQ8.java
File metadata and controls
58 lines (41 loc) · 1.39 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.util.Locale;
import java.util.Scanner;
public class Q8 {
public static void main(String[] args) {
Locale.setDefault(Locale.US);
Scanner sc = new Scanner(System.in);
int l = sc.nextInt();
int c = sc.nextInt();
double[][] notas = new double[l][c];
for (int i = 0; i < l; i++) {
for (int j = 0; j < c; j++) {
notas[i][j] = sc.nextDouble();
}
}
calculo(notas, l, c);
sc.close();
}
public static void calculo(double[][] notas, int l, int c) {
int aprovados = 0;
for (int i = 0; i < l; i++) {
double soma = 0;
for (int j = 0; j < c; j++) {
soma += notas[i][j];
}
double mediaAluno = soma / c;
System.out.printf("Media do aluno %d: %.2f\n", i, mediaAluno);
if (mediaAluno >= 7.0) {
aprovados++;
}
}
for (int j = 0; j < c; j++) {
double soma = 0;
for (int i = 0; i < l; i++) {
soma += notas[i][j];
}
double mediaAvaliacoes = soma / l;
System.out.printf("Media da avaliacao %d: %.2f\n", j, mediaAvaliacoes);
}
System.out.println("Quantidade de alunos aprovados: " + aprovados);
}
}