import java.util.Scanner ;
import java.util.ArrayList ;
class Media {
public static void main
( String [ ] args
) { ArrayList< Float> valores= new ArrayList< Float> ( ) ;
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 ;
}
valores.add ( valor) ;
contador++;
acumulador += valor;
System .
out .
println ( "Deseja inserir outro valor S/N? " ) ; if ( ! scanner.next ( ) .equals ( "S" ) ) {
break ;
}
}
for ( int i = 0 ; i < valores.size ( ) ; i++ ) {
System .
out .
println ( "Nota " + ( i
+ 1 ) + ": " + valores.
get ( i
) ) ; }
System .
out .
println ( "Média: " + acumulador
/ contador
) ; }
}
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwppbXBvcnQgamF2YS51dGlsLkFycmF5TGlzdDsKCmNsYXNzIE1lZGlhIHsKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKICAgICAgICBBcnJheUxpc3Q8RmxvYXQ+IHZhbG9yZXM9IG5ldyBBcnJheUxpc3Q8RmxvYXQ+KCk7CiAgICAgICAgZmxvYXQgYWN1bXVsYWRvciA9IDA7CiAgICAgICAgaW50IGNvbnRhZG9yID0gMDsKICAgICAgICBTY2FubmVyIHNjYW5uZXIgPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwogICAgICAgIHdoaWxlICh0cnVlKSB7CiAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiSW5zaXJhIHVtIHZhbG9yOiAiKTsKICAgICAgICAgICAgZmxvYXQgdmFsb3IgPSBzY2FubmVyLm5leHRGbG9hdCgpOwogICAgICAgICAgICBpZiAoZmFsc2UpIHsgLy92YWkgY29sb2NhciBhIHZhbGlzYcOnw6NvIGFxdWkKICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiVmFsb3IgaW52w6FsaWRvIGRpZ2l0ZSB1bSB2w6FsaWRvIik7CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICB2YWxvcmVzLmFkZCh2YWxvcik7CiAgICAgICAgICAgIGNvbnRhZG9yKys7CiAgICAgICAgICAgIGFjdW11bGFkb3IgKz0gdmFsb3I7CiAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiRGVzZWphIGluc2VyaXIgb3V0cm8gdmFsb3IgUy9OPyAiKTsKICAgICAgICAgICAgaWYgKCFzY2FubmVyLm5leHQoKS5lcXVhbHMoIlMiKSkgewogICAgICAgICAgICAJYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCB2YWxvcmVzLnNpemUoKTsgaSsrKSB7CiAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiTm90YSAiICsgKGkgKyAxKSArICI6ICIgKyB2YWxvcmVzLmdldChpKSk7CiAgICAgICAgfQogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiTcOpZGlhOiAiKyBhY3VtdWxhZG9yIC8gY29udGFkb3IpOwogICAgfQp9