Java - Tengo problemas con este ejercicio y no se que significa los errores

 
Vista:

Tengo problemas con este ejercicio y no se que significa los errores

Publicado por Jose Antonio (1 intervención) el 23/02/2012 21:10:05
Os paso el ejercicio programado, el resultado que me da y el que me deberia dar, podriais orientarme que es lo que hago mal:

/*
* Ejercicio de asigancion de variables y operaciones
*
*/
package prog02_ejer10;

/**
*
* @author JOSE ANTONIO GOMEZ MARTINEZ
*/
public class PROG02_Ejer10 {


public static void main(String[] args) {
float x = 4.5f, y = 3.0f;
int i = 2;
double dx = 2.0;
byte bx = 5, by =2;
short sx = 5, sy = 2;
char cx = '\u000F', cy = '\u0001';




System.out.println("------ Conversiones entre enteros y coma flotante ------");

int j = (int) (i*x);
double dz = dx*y;

System.out.println("Producto de int por float: j = i*x = "+ j);
System.out.println("Producto de float por double: dz=dx * y = " +dz);

System.out.println("------ Operaciones con byte ------");
byte bz = (byte) (bx - by);

System.out.println("byte: 5 - 2 = "+ bz);

bx = -128;
by = 1;
bz = (byte) (bx - by);

System.out.println("byte -128 - 1 = "+bz);

System.out.println("(int) (-128 - 1) = "+(int) (bx - by));


System.out.println("------ Operaciones con short ------");

short sz = (short) (sx - sy);
System.out.println("short: 10 - 1 = "+sz);

sx = 32767;
sz = (short) (sx + sy);
System.out.println("short 32767 + 1 = "+sz);


System.out.println("------ Operaciones con char ------");


int z = cx - cy;


System.out.println("char: - = " + z);


z = cx - 1;

System.out.println("char(0x000F) - 1 = " + z);

cx = '\uFFFF';
z = cx;

System.out.println("(int) egg = "+ z);

sx = (short) cx;

System.out.println("(short) egg = ");

sx = -32768;
cx = (char) sx;
z = sx;

System.out.println("-32768 short-char-int = ");

sx = -1;
z = cx;
z cx - 1;


System.out.println("-1 short-char-int = ");


}
}


RESULTADO

run:
------ Conversiones entre enteros y coma flotante ------
Producto de int por float: j = i*x = 9
Producto de float por double: dz=dx * y = 6.0
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cx is already defined in main(java.lang.String[])
------ Operaciones con byte ------
at prog02_ejer10.PROG02_Ejer10.main(PROG02_Ejer10.java:87)
byte: 5 - 2 = 3
byte -128 - 1 = 127
(int) (-128 - 1) = -129
------ Operaciones con short ------
short: 10 - 1 = 3
short 32767 + 1 = -32767
------ Operaciones con char ------
char: - = 14
char(0x000F) - 1 = 14
(int) egg = 65535
(short) egg =
-32768 short-char-int =
Java Result: 1
GENERACIÓN CORRECTA (total time: 2 seconds)

Y EL RESULTADO QUE ME DEBERIA HABER DADO ES
El resultado del programa debe ser el siguiente:
------- Conversiones entre enteros y coma flotante -------
Producto de int por float: j= i*x = 9
Producto de float por double: dz=dx * y = 6.0
------- Operaciones con byte -------
byte: 5 - 2 = 3
byte -128 - 1 = 127
(int)(-128 - 1) = -129
------- Operaciones con short -------
short: 10 - 1 = 3
short 32767 + 1 = -32768
------- Operaciones con char -------
char: - = 14
char(0x000F) - 1 = 14
(int) = 65535
(short) = -1
-32768 short-char-int = 32768
-1 short-char-int = 65535
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