-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseis.java
More file actions
35 lines (28 loc) · 1.13 KB
/
seis.java
File metadata and controls
35 lines (28 loc) · 1.13 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
import java.util.Scanner;
public class seis {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
boolean novoCalculo;
do {
double nota1 = lerNota(scanner, 1);
double nota2 = lerNota(scanner, 2);
double media = (nota1 + nota2) / 2;
System.out.printf("A media do aluno e: %.2f%n", media);
System.out.print("NOVO CALCULO (S/N)? ");
String resposta = scanner.next().trim().toUpperCase();
novoCalculo = resposta.equals("S");
} while (novoCalculo);
scanner.close();
}
private static double lerNota(Scanner scanner, int avaliacao) {
double nota;
do {
System.out.printf("Digite a nota da %da avaliacao (0 a 10): ", avaliacao);
nota = scanner.nextDouble();
if (nota < 0 || nota > 10) {
System.out.println("VALOR INVALIDO. A nota deve estar entre 0 e 10.");
}
} while (nota < 0 || nota > 10);
return nota;
}
}