Advertisement
Montoya-Romina-Anahi

Tp_2_Punto_6_Principal

May 22nd, 2020
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. import java.util.Stack;
  2.  
  3. import javax.swing.JOptionPane;
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class Principal {
  8.  
  9. public static void main(String[] args) {
  10.  
  11. Stack<Orden> pila = new Stack();
  12. Scanner entrada = new Scanner(System.in);
  13.  
  14. int numero_Afiliados,codigo_Estudio,opcion,aprobarOrden;
  15. double descuento;
  16. String matricula,fecha,estado;
  17.  
  18. numero_Afiliados = 0;
  19. codigo_Estudio = 0;
  20. descuento = 0;
  21. matricula = "";
  22. fecha = "";
  23. estado = "";
  24. opcion = 0;
  25.  
  26. while(opcion != 3){
  27. opcion = Integer.parseInt(JOptionPane.showInputDialog(null,
  28. "1.- Agregar orden\n"+
  29. "2.- Revisar ordenes\n"+
  30. "3.- Salir","Menu de opciones",3));
  31.  
  32. switch(opcion) {
  33. case 1:
  34. numero_Afiliados = Integer.parseInt(JOptionPane.showInputDialog(null,"Ingrese numero de afiliado","Numero de Afiliado",3));
  35. codigo_Estudio = Integer.parseInt(JOptionPane.showInputDialog(null,"Ingrese codigo de estudio","Codigo de Estudio",3));
  36. matricula = JOptionPane.showInputDialog(null,"Ingrese matricula profesional del medico solicitante","Matricula",3);
  37. fecha = JOptionPane.showInputDialog(null,"Ingrese fecha","Fecha",3);
  38. estado = "";
  39. descuento = 0;
  40. Orden carga = new Orden(numero_Afiliados,codigo_Estudio,matricula,fecha,estado,descuento);
  41. pila.push(carga);
  42. break;
  43. case 2:
  44. if(pila.isEmpty()) {
  45. JOptionPane.showMessageDialog(null, "NO hay ordenes para revisar");
  46. }else {
  47. while (!pila.isEmpty()) {
  48. carga = pila.pop();
  49. JOptionPane.showMessageDialog(null, "Numero de Afiliado: "+Integer.toString(carga.numero_Afiliado)+
  50. "\nCodigo de Estudio: "+Integer.toString(carga.codigo_Estudio)+
  51. "\nMatricula: "+carga.matricula+
  52. "\nFecha: "+carga.fecha);
  53. aprobarOrden = Integer.parseInt(JOptionPane.showInputDialog(null,
  54. "1.- Aprobar orden\n"+
  55. "2.- Desaprobar ordenes\n"
  56. ,"Menu de opciones",3));
  57. if(aprobarOrden == 1) {
  58. carga.estado = "Aprobado";
  59. descuento = Double.parseDouble(JOptionPane.showInputDialog(null,"Ingrece porsentaje de descuento","Descuento",3));
  60. carga.descuento = descuento;
  61. }else if(aprobarOrden == 2) {
  62. carga.estado = "Desaprobado";
  63. carga.descuento = 0;
  64. }
  65. }
  66. }
  67. break;
  68. default: JOptionPane.showMessageDialog(null, "El valor ingresado es incorrecto!!!");
  69. }
  70. }
  71. }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement