diff --git a/1ano/2semestre/poo/src/aula03/Grades.java b/1ano/2semestre/poo/src/aula03/Grades.java index 4af54d7..c3426a4 100644 --- a/1ano/2semestre/poo/src/aula03/Grades.java +++ b/1ano/2semestre/poo/src/aula03/Grades.java @@ -3,7 +3,7 @@ package aula03; import java.util.Scanner; import utils.UserInput; -// Solução do exercício 4 +// Solução do exercício 4 com o utilizador a introduzir as notas individualmente public class Grades { private static final Scanner sin = new Scanner(System.in); diff --git a/1ano/2semestre/poo/src/aula03/GradesRandom.java b/1ano/2semestre/poo/src/aula03/GradesRandom.java new file mode 100644 index 0000000..3ee3ad8 --- /dev/null +++ b/1ano/2semestre/poo/src/aula03/GradesRandom.java @@ -0,0 +1,24 @@ +package aula03; + + +// Solução do exercício 4 com notas aleatórias + +import java.util.Random; +import java.util.Scanner; + +public class GradesRandom { + private static final Scanner sin = new Scanner(System.in); + private static final Random rand = new Random(); + + public static void main(String[] args) { + System.out.print("Quantos alunos tem a turma? "); + int studentCount = sin.nextInt(); + + System.out.println("NotaT NotaP Pauta"); + for (int i = 0; i < studentCount; i++) { + double notaT = rand.nextDouble(0, 20); + double notaP = rand.nextDouble(0, 20); + System.out.printf("%5.1f %5.1f %5d\n", notaT, notaP, (notaT < 7 || notaP < 7) ? 66 : (int) Math.round(0.4 * notaT + 0.6 * notaP)); + } + } +}