forked from maniero/SOpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInserting2.java
More file actions
24 lines (22 loc) · 789 Bytes
/
Copy pathInserting2.java
File metadata and controls
24 lines (22 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import java.util.Scanner;
class Media {
public static void main(String[] args) {
float acumulador = 0;
int contador = 0;
Scanner scanner = new Scanner(System.in);
while (true) {
System.out.println("Insira um valor: ");
float valor = scanner.nextFloat();
if (false) { //vai colocar a valisação aqui
System.out.println("Valor inválido digite um válido");
continue;
}
contador++;
acumulador += valor;
System.out.println("Deseja inserir outro valor S/N? ");
if (!scanner.next().equals("S")) break;
}
System.out.println("Média: "+ acumulador / contador);
}
}
//https://pt.stackoverflow.com/q/153379/101