Hola amigos tengo un problema con este código
import java.util.*;
public class Exa
{
public static void main
(String args
[]) {
Scanner sc
= new Scanner
(System.
in); int x=0, y=0, r=0;
int []a = new int[10];
for(int pos=0; pos<a.length; pos++)
{
System.
out.
print("Valor ["+pos
+"]: "); a[pos]=sc.nextInt();
}
for(int pos=0; pos<a.length; pos++)
{
if(a[pos]<5)
{
x=x+1;
y=a[pos];
r=y/x;
}
}
System.
out.
print("Tu promedio es = "+r
); }
}
Al compilar no pasa nada el problema esta al correrlo que me muestra lo siguiente:
Valor
- : Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Exa.main(Exa.java:26)
Ayuda y muchas Gracias.
· Los códigos deben ir en etiquetas GeSHi
>aquí las reglas del foro
-Engel Lex