Ayuda con este programa
Publicado por Alfonso Jose Torres Morales (7 intervenciones) el 02/11/2007 19:57:52
mi consulta es la siguiente, se necesita realizar un programa que ingresando un numero, por ejemplo el 1, aparezca por pantalla el dia de la semana que le corresponde, como por ejemplo Lunes, si se digita dos, Martes y asi sucesivamente, bien este programa que aparece a continuación, cumple con lo pedido, solo que por una cosa no esta bien
EL PROGRAMA ES ESTE:
import javax.swing.JOptionPane;
public class tarea1{
public static void main (String args[])
{
String numero;
int num=0;
int resultado=1;
int resultado1=2;
int resultado2=3;
int resultado3=4;
int resultado4=5;
int resultado5=6;
int resultado6=7;
numero = JOptionPane.showInputDialog("Escriba el numero del dia de la semana que quiere observar : ");
num=Integer.parseInt(numero);
if(num == 1){
JOptionPane.showMessageDialog(null,"Es lunes "+ resultado,"Resultado",JOptionPane.PLAIN_MESSAGE);
}else if(num == 2){
JOptionPane.showMessageDialog(null,"Es Martes: "+ resultado1,"Resultado",JOptionPane.PLAIN_MESSAGE);
}else if(num == 3)
JOptionPane.showMessageDialog(null,"Es Miercoles: "+ resultado2,"Resultado",JOptionPane.PLAIN_MESSAGE);
else if(num == 4)
JOptionPane.showMessageDialog(null,"Es Jueves: "+ resultado3,"Resultado",JOptionPane.PLAIN_MESSAGE);
else if(num == 5)
JOptionPane.showMessageDialog(null,"Es Viernes: "+resultado4,"Resultado",JOptionPane.PLAIN_MESSAGE);
else if(num == 6)
JOptionPane.showMessageDialog(null,"Es Sabado: "+ resultado5,"Resultado",JOptionPane.PLAIN_MESSAGE);
else if(num == 7)
JOptionPane.showMessageDialog(null,"Es Domingo: "+ resultado6,"Resultado",JOptionPane.PLAIN_MESSAGE);
}
}
BUENO ESTE PROGRAMA CUMPLE CON LO PEDIDO, PERO NO SE PUEDE REALIZAR DE ESTA FORMA SI NO CON ARREGLOS, LOS TAMBIEN LLAMADOS ARRAYS, BUENO, MI
PREGUNTA ES ¿COMO PUEDO DESARROLLAR ESTE PROGRAMA PERO CON ARRAYS?
TODA LA YUDA BRINDADA SERA DE MUCHA AYUDA, GRACIAS
EL PROGRAMA ES ESTE:
import javax.swing.JOptionPane;
public class tarea1{
public static void main (String args[])
{
String numero;
int num=0;
int resultado=1;
int resultado1=2;
int resultado2=3;
int resultado3=4;
int resultado4=5;
int resultado5=6;
int resultado6=7;
numero = JOptionPane.showInputDialog("Escriba el numero del dia de la semana que quiere observar : ");
num=Integer.parseInt(numero);
if(num == 1){
JOptionPane.showMessageDialog(null,"Es lunes "+ resultado,"Resultado",JOptionPane.PLAIN_MESSAGE);
}else if(num == 2){
JOptionPane.showMessageDialog(null,"Es Martes: "+ resultado1,"Resultado",JOptionPane.PLAIN_MESSAGE);
}else if(num == 3)
JOptionPane.showMessageDialog(null,"Es Miercoles: "+ resultado2,"Resultado",JOptionPane.PLAIN_MESSAGE);
else if(num == 4)
JOptionPane.showMessageDialog(null,"Es Jueves: "+ resultado3,"Resultado",JOptionPane.PLAIN_MESSAGE);
else if(num == 5)
JOptionPane.showMessageDialog(null,"Es Viernes: "+resultado4,"Resultado",JOptionPane.PLAIN_MESSAGE);
else if(num == 6)
JOptionPane.showMessageDialog(null,"Es Sabado: "+ resultado5,"Resultado",JOptionPane.PLAIN_MESSAGE);
else if(num == 7)
JOptionPane.showMessageDialog(null,"Es Domingo: "+ resultado6,"Resultado",JOptionPane.PLAIN_MESSAGE);
}
}
BUENO ESTE PROGRAMA CUMPLE CON LO PEDIDO, PERO NO SE PUEDE REALIZAR DE ESTA FORMA SI NO CON ARREGLOS, LOS TAMBIEN LLAMADOS ARRAYS, BUENO, MI
PREGUNTA ES ¿COMO PUEDO DESARROLLAR ESTE PROGRAMA PERO CON ARRAYS?
TODA LA YUDA BRINDADA SERA DE MUCHA AYUDA, GRACIAS
Valora esta pregunta


0