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
) ; }
}
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwoKY2xhc3MgTWVkaWEgewogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIGZsb2F0IGFjdW11bGFkb3IgPSAwOwogICAgICAgIGludCBjb250YWRvciA9IDA7CiAgICAgICAgU2Nhbm5lciBzY2FubmVyID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKICAgICAgICB3aGlsZSAodHJ1ZSkgewogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkluc2lyYSB1bSB2YWxvcjogIik7CiAgICAgICAgICAgIGZsb2F0IHZhbG9yID0gc2Nhbm5lci5uZXh0RmxvYXQoKTsKICAgICAgICAgICAgaWYgKGZhbHNlKSB7IC8vdmFpIGNvbG9jYXIgYSB2YWxpc2HDp8OjbyBhcXVpCiAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIlZhbG9yIGludsOhbGlkbyBkaWdpdGUgdW0gdsOhbGlkbyIpOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGFkb3IrKzsKICAgICAgICAgICAgYWN1bXVsYWRvciArPSB2YWxvcjsKICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJEZXNlamEgaW5zZXJpciBvdXRybyB2YWxvciBTL04/ICIpOwogICAgICAgICAgICBpZiAoIXNjYW5uZXIubmV4dCgpLmVxdWFscygiUyIpKSB7CiAgICAgICAgICAgIAlicmVhazsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIk3DqWRpYTogIisgYWN1bXVsYWRvciAvIGNvbnRhZG9yKTsKICAgIH0KfQ==