package casita;
import javax.swing.JOptionPane;
public class diashorasminu {
public static void main(String[] args) {
float dia,hor,min,seg;
int salir;
String opcion;
dia=1;hor=1;min=1;seg=1;
salir=0;
while (salir!=1){
dia =Float.parseFloat( JOptionPane.showInputDialog(
null,"Introduzca el numero de dias ",
"Dia",
JOptionPane.QUESTION_MESSAGE) );
hor =Float.parseFloat( JOptionPane.showInputDialog(
null,"Introduzca el numero de horas ",
"Horas",
JOptionPane.QUESTION_MESSAGE) );
min =Float.parseFloat( JOptionPane.showInputDialog(
null,"Introduzca el numero de minutos ",
"Minutos",
JOptionPane.QUESTION_MESSAGE) );
seg =Float.parseFloat( JOptionPane.showInputDialog(
null,"Introduzca el numero de segundos ",
"Segundos",
JOptionPane.QUESTION_MESSAGE) );
opcion =JOptionPane.showInputDialog(
null,
"\n a.-Conversion a segundos "+
"\n b.-Conversion a minutos "+
"\n c.-Conversion a horas "+
"\n d.-Conversion a dias "+
"\n Elige una opcion ",
"Coversion",
JOptionPane.QUESTION_MESSAGE) ;
switch(opcion){
case "a":{JOptionPane.showMessageDialog(null , "\nLos segundos son "+Math.rint(((dia*86400)+(hor*3600)+(min*60)+seg)*100) /100,"Segundos",
JOptionPane.INFORMATION_MESSAGE);}break;
case "b":{JOptionPane.showMessageDialog(null , "\nLos minutos son "+Math.rint(((dia*1440)+(hor*60)+(min*1)+seg/60)*100)/100 ,"Minutos",
JOptionPane.INFORMATION_MESSAGE);}break;
case "c":{JOptionPane.showMessageDialog(null , "\nLos horas son "+ Math.rint(((dia*24)+(hor*1)+(min/60)+seg/3600)*100)/100 ,"Horas",
JOptionPane.INFORMATION_MESSAGE);}break;
case "d":{JOptionPane.showMessageDialog(null , "\nLos dias son "+ Math.rint(((dia*1)+(hor/24)+(min/1440)+seg/86400)*100)/100 ,"Dias",
JOptionPane.INFORMATION_MESSAGE);}break;
}
salir = JOptionPane.showConfirmDialog(null, "Desea seguir ejecutando la aplicacion?", "Seleccione una opcion", JOptionPane.YES_NO_OPTION);
}
}
}
No hay comentarios:
Publicar un comentario