domingo, 19 de julio de 2009

NUMERO MAYOR EN JAVA

INGRESE POR TECLADO 10 NÚMEROS SIN NINGÚN ORDEN, VISUALICE EL MAYOR.


Realizar el siguiente formulario en Netbeans





Cambiamos de nombre de la Variable(JTextField1) por txtnum1
Cambiamos de nombre
de la Variable(JTextField2) por txtnum2Cambiamos de nombre de la Variable(JTextField3) por txtnum3
Cambiamos de nombre de la Variable(JTextField4) por txtnum4Cambiamos de nombre de la Variable(JTextField5) por txtnum5Cambiamos de nombre de la Variable(JTextField6) por txtnum6
Cambiamos de nombre de la Variable(JTextField7) por txtnum7Cambiamos de nombre de la Variable(JTextField8) por txtnum8
Cambiamos de nombre de la Variable(JTextField9) por txtnum9Cambiamos de nombre de la Variable(JTextField10) por txtnum10


Cambiamos de nombre
de la Variable(jButton1) por btnnuevoCambiamos de nombre de la Variable(jButton2) por btnmostrarCambiamos de nombre de la Variable(jButton3) por btnsalir
CODIGOS DE LOS BOTONES

CODIGO BOTON NUEVO


txtmun1.setText("");
txtnum2.setText("");
txtnum3.setText("");
txtnum4.setText("");
txtnum5.setText("");
txtnum6.setText("");
txtnum7.setText("");
txtnum8.setText("");
txtnum9.setText("");
txtnum10.setText("");
txtmayor.setText("");


CODIGO BOTON MOSTRAR
//variables
int n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,nmay,xnmay;
int xmax1,xmax2,xmax3,xmax4,xmax5,xmax6,xmax7;

//leer

n1 = Integer.parseInt(txtmun1.getText().trim());
n2 = Integer.parseInt(txtnum2.getText().trim());
n3 = Integer.parseInt(txtnum3.getText().trim());
n4 = Integer.parseInt(txtnum4.getText().trim());
n5 = Integer.parseInt(txtnum5.getText().trim());
n6 = Integer.parseInt(txtnum6.getText().trim());
n7 = Integer.parseInt(txtnum7.getText().trim());
n8 = Integer.parseInt(txtnum8.getText().trim());
n9 = Integer.parseInt(txtnum9.getText().trim());
n10 = Integer.parseInt(txtnum10.getText().trim());

//proceso

nmay = Math.max(n1, n2);
xnmay = Math.max(nmay, n3);
xmax1 = Math.max(xnmay, n4);
xmax2 = Math.max(xmax1, n5);
xmax3 = Math.max(xmax2, n6);
xmax4 = Math.max(xmax3, n7);
xmax5 = Math.max(xmax4, n8);
xmax6 = Math.max(xmax5, n9);
xmax7 = Math.max(xmax6, n10);

//escribir

txtmayor.setText(String.valueOf(xmax7));

CODIGO BOTON SALIR

System.exit(0);

RESULTADO FINAL

0 comentarios:

Publicar un comentario

elemptymundoemptydeemptylosemptycodigosemptyjava

Cualquier consulta escribanme a mi correo o dejen un comentario

Copyright @2009

Copyright @2009
Esta Wed ha sido creado por Juan Alejandro Rosales Coronel