Java - NECESITO AYUDA!!

 
Vista:

NECESITO AYUDA!!

Publicado por Hela (1 intervención) el 25/10/2021 14:21:31
iseña un programa Java, que realice las siguientes operaciones, en el orden que se muestran. Se indica la variable y el tipo de dato que recibe el valor o resultado de la operación indicada:

Tipo_Variable

Variable

Valor / Operación

float

x

4.5

float

y

3.0

int

i

2

int

j

i * x

double

dx

2.0

double

dz

dx * y

byte

bx

5

byte

by

2

byte

bz

bx - by

byte

bx

-128

byte

by

1

byte

bz

bx – by (resultado tipo byte)

byte

bz

bx – by (resultado tipo int)

short

sx

5

short

sy

2

short

sz

sx - sy

short

sx

32767

short

sy

1

short

sz

sx + sy

char

cx

\u000F

char

cy

\u0001

int

z

cx – cy

int

z

cx – 1

char

cx

\uFFFF

int

z

cx

short

sx

cx

short

sx

-32768

char

cx

sx

int

z

sx

short

sx

-1

char

cx

sx

int

z

cx


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