Java - Java NumberFormatException

 
Vista:

Java NumberFormatException

Publicado por Daniel (2 intervenciones) el 11/12/2007 20:17:50
El siguiente codigo me tira un NumberFormatException, lo raro es que lo hace bien la 1ra vez y cuando pregunto si desea ingresar otra compra, al ponerle 's', me tira el error.
Alguien me puede ayudar ¿?

static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static String a;
static int[,] mat = new int[6,4];
public static void main(String[] args) throws IOException
{
int suc, art;
char r;
int[,] com = new int[6,4];
do
{
System.out.println("Ingrese la sucursal");
a = br.readLine();
suc = Integer.parseInt(a);
System.out.println("Ingrese el articulo");
a = br.readLine();
art = Integer.parseInt(a);
System.out.println("Ingrese la compra");
a = br.readLine();
com[art - 1, suc - 1] = Integer.parseInt(a);
mat[art - 1, suc - 1] = mat[art - 1, suc - 1] + com[art - 1, suc - 1];
System.out.println("Desea ingresar otra compra");
r = (char)System.in.read();
}
while(r=='s');
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Java NumberFormatException

Publicado por mario (622 intervenciones) el 11/12/2007 21:51:02
Sip tenias un error

/*
* COPYRIGHT. HSBC HOLDINGS PLC 2007. ALL RIGHTS RESERVED.
*
* This software is only to be used for the purpose for which it has been
* provided. No part of it is to be reproduced, disassembled, transmitted,
* stored in a retrieval system nor translated in any human or computer
* language in any way or for any other purposes whatsoever without the
* prior written consent of HSBC Holdings plc.
*/
package org.neos.io;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
* @author Mario Hidalgo Martinez
*
*/
public class Test {

static BufferedReader br =
new BufferedReader(new InputStreamReader(System.in));
static String a;
static int[][] mat = new int[6][4];
public static void main(String[] args) throws IOException {
int suc, art;
char r;
int[][] com = new int[6][4];
do {
System.out.println("Ingrese la sucursal");
a = br.readLine();
suc = Integer.parseInt(a);
System.out.println("Ingrese el articulo");
a = br.readLine();
art = Integer.parseInt(a);
System.out.println("Ingrese la compra");
a = br.readLine();
com[art - 1][suc - 1] = Integer.parseInt(a);
mat[art - 1][suc - 1] = mat[art - 1]
[suc - 1] + com[art - 1]
[suc - 1];
System.out.println("Desea ingresar otra compra");
a= br.readLine();
} while (a.equalsIgnoreCase("s"));
}
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Java NumberFormatException

Publicado por daniel (2 intervenciones) el 12/12/2007 00:17:16
ooh vaya, gracias en vdd x tu tiempo y ayuda mario =)
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar