-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcinco.java
More file actions
38 lines (29 loc) · 1.2 KB
/
cinco.java
File metadata and controls
38 lines (29 loc) · 1.2 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
import java.util.Scanner;
public class cinco {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
char continuar;
do {
double nota1, nota2;
do {
System.out.print("Digite a primeira nota (0 a 10): ");
nota1 = scanner.nextDouble();
if (nota1 < 0 || nota1 > 10) {
System.out.println("Nota invalida Deve estar entre 0 e 10.");
}
} while (nota1 < 0 || nota1 > 10);
do {
System.out.print("Digite a segunda nota (0 a 10): ");
nota2 = scanner.nextDouble();
if (nota2 < 0 || nota2 > 10) {
System.out.println("Nota invalida Deve estar entre 0 e 10.");
}
} while (nota2 < 0 || nota2 > 10);
double media = (nota1 + nota2) / 2;
System.out.println("A media do aluno e: " + media);
System.out.print("NOVO CALCULO (S/N)? ");
continuar = scanner.next().charAt(0);
} while (continuar == 'S' || continuar == 's');
scanner.close();
}
}