matrices
Publicado por monik (2 intervenciones) el 12/10/2008 17:39:48
mi problema esta en que realizo todo el codigo y me aparece un error que no entiendo.
es k estoy pasando los problemas de c a java, y no se cual podra ser le problema
hatsa el momento lo llebo asi
import java.io.*;
public class punto4 {
public static void main(String[] args) throws IOException {
BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
int [][]m;
double total;
int fi;
int columnas;
int x;
int y;
System.out. print("ingrese el numero de filas");
fi = Integer.parseInt(scan.readLine());
System.out. print("ingrese el numero a columnas");
columnas = Integer.parseInt(scan.readLine());
m=new int [fi][columnas];
for(x=0;x<m.length;x++){
for(y=0;y<m[x].length;y++){
m[x][y]=TecladoIn.readLineInt();
}
}
total=promedio(m,fi,columnas);
System.out. print("el promedio es de:" + total);
}
public static double promedio(int m[][],int filas, int col){
int x;
int y;
int suma=0;
double promedio;
for(x=0;x<filas;x++){
for(y=0;y<col;y++){
suma=suma+m[x][y];
}
}
promedio=suma/(filas*col);
return promedio;
}
}
pero me aparece que Exception in thread "main" java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:468)
at java.lang.Integer.parseInt(Integer.java:497)
at punto4.main(punto4.java:30)
es k estoy pasando los problemas de c a java, y no se cual podra ser le problema
hatsa el momento lo llebo asi
import java.io.*;
public class punto4 {
public static void main(String[] args) throws IOException {
BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
int [][]m;
double total;
int fi;
int columnas;
int x;
int y;
System.out. print("ingrese el numero de filas");
fi = Integer.parseInt(scan.readLine());
System.out. print("ingrese el numero a columnas");
columnas = Integer.parseInt(scan.readLine());
m=new int [fi][columnas];
for(x=0;x<m.length;x++){
for(y=0;y<m[x].length;y++){
m[x][y]=TecladoIn.readLineInt();
}
}
total=promedio(m,fi,columnas);
System.out. print("el promedio es de:" + total);
}
public static double promedio(int m[][],int filas, int col){
int x;
int y;
int suma=0;
double promedio;
for(x=0;x<filas;x++){
for(y=0;y<col;y++){
suma=suma+m[x][y];
}
}
promedio=suma/(filas*col);
return promedio;
}
}
pero me aparece que Exception in thread "main" java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:468)
at java.lang.Integer.parseInt(Integer.java:497)
at punto4.main(punto4.java:30)
Valora esta pregunta


0