-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpathProjeto.patch
More file actions
78 lines (76 loc) · 2.22 KB
/
pathProjeto.patch
File metadata and controls
78 lines (76 loc) · 2.22 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
From cf5a3e39db2766da395f705c7c86bdd6f4b433e8 Mon Sep 17 00:00:00 2001
From: aguedes2 <aguedes2@gmail.com>
Date: 27/06/2016 00:29:24
Aula21
diff --git a/src/com/cursobasicojava/aula21/ForEach.java b/src/com/cursobasicojava/aula21/ForEach.java
new file mode 100644
index 0000000..64797d8
--- /dev/null
+++ b/src/com/cursobasicojava/aula21/ForEach.java
@@ -0,0 +1,66 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.cursobasicojava.aula21;
+
+import java.util.Random;
+
+/**
+ *
+ * @author fernando
+ */
+public class ForEach {
+ public static void main(String[] args) {
+
+ Random aleatorio = new Random();
+
+ int[] notas = new int [10];
+
+ for(int i = 0; i < notas.length; i++){
+ notas[i] = aleatorio.nextInt(11);
+ }
+
+ //imprimindo os termos com ForEach
+ for(int nota : notas){
+ System.out.print(nota+" ");
+ }System.out.println("");
+
+ //Array com foreach
+ System.out.println("************************************");
+ int[][] notasAlunos = new int[3][4];
+
+
+ for(int i=0; i < notasAlunos.length; i++){
+ for(int j = 0; j< notasAlunos[i].length; j++){
+ notasAlunos[i][j] = aleatorio.nextInt(11);
+ }
+ }
+
+ //imprimir
+ int k = 1;
+
+ for(int[] notaAluno : notasAlunos) //Percorre as linhas
+ {
+ System.out.println("Notas aluno "+k);
+ int j = 0;
+ int soma = 0;
+ double media;
+ for(int nota : notaAluno) //Percorre as colunas
+ {
+ j++;
+ System.out.print(nota+ " ");
+ soma +=nota;
+ }System.out.println("");
+ media = soma/j;
+ System.out.printf("Media aluno %d = %.2f ",k,Math.ceil(media));
+ if(media >= 6){
+ System.out.println("--> Aprovado");
+ }else{
+ System.out.println("--> Reprovado");
+ }
+ k++;
+ }
+ }
+}