-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrizes.java
More file actions
93 lines (52 loc) · 1.61 KB
/
Matrizes.java
File metadata and controls
93 lines (52 loc) · 1.61 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package com.laiane.cursojava.aula20;
import java.util.Scanner;
public class Matrizes {
public static void main(String[] args) {
double[][] notasAlunos = new double[3][4];
notasAlunos[0][0] = 10;
notasAlunos[0][1] = 7;
notasAlunos[0][2] = 9;
notasAlunos[0][3] = 9.5;
notasAlunos[1][0] = 9;
notasAlunos[1][1] = 8;
notasAlunos[1][2] = 7;
notasAlunos[1][3] = 9;
notasAlunos[2][0] = 8;
notasAlunos[2][1] = 9;
notasAlunos[2][2] = 10;
notasAlunos[2][3] = 7;
for (int i=0; i<notasAlunos.length; i++){
//System.out.print(notasAlunos[i] + " ");
for (int j=0; j<notasAlunos[i].length; j++){
System.out.print(notasAlunos[i][j] + " - ");
}
System.out.println();
}
notasAlunos[1][3] = 8;
System.out.println();
for (int i=0; i<notasAlunos.length; i++){
for (int j=0; j<notasAlunos[i].length; j++){
System.out.print(notasAlunos[i][j] + " - ");
}
System.out.println();
}
System.out.println("Calculando a média de cada aluno");
double soma;
for (int i=0; i<notasAlunos.length; i++){
soma = 0;
for (int j=0; j<notasAlunos[i].length; j++){
soma += notasAlunos[i][j];
}
System.out.println("Média do aluno " + i + " é = " + (soma/4));
}
double[] notasAluno1 = {7, 8, 9, 10};
double[][] notasAlunos2 = {{7, 8, 9, 10}, {8, 6, 7, 10}};
System.out.println("Output da matriz notasAlunos2");
for (int i=0; i<notasAlunos2.length; i++){
for (int j=0; j<notasAlunos2[i].length; j++){
System.out.print(notasAlunos2[i][j] + " - ");
}
System.out.println();
}
}
}