Advertisement
Guest User

Parcial dos

a guest
Sep 20th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.51 KB | None | 0 0
  1. package cajeroautomatico;
  2. import javax.swing.JOptionPane;
  3. import java.util.Scanner;
  4. public class cajero {
  5. public static void main (String[]args) {
  6. Scanner entrada=new Scanner(System.in);
  7.  
  8.  
  9. int retiros[], depositos[], auxDepositos, auxRetiros, opcion, qRetiros=0, qDepositos=0, valorRetiros = 0, valorDeposito;
  10. float aux;
  11. String nombreCliente, tipoCuenta;
  12. int totalretiros = 0, total;
  13. float arreglo[];
  14. float saldo, saldod=0, saldor = 0;
  15. int nelementos1=totalretiros;
  16. int totaldepositos = 0;
  17. int nelementos2=totaldepositos;
  18. depositos = new int [3];
  19. retiros = new int [3];
  20. nombreCliente =JOptionPane.showInputDialog("Por favor digite su nombre");
  21. tipoCuenta =JOptionPane.showInputDialog("Por favor digite el tipo de cuenta");
  22. saldo =Float.parseFloat(JOptionPane.showInputDialog("Por favor ingrese el saldo inicial"));
  23. do {
  24. opcion = Integer.parseInt(JOptionPane.showInputDialog("Seleccione una opción: \n"
  25. +"1.DEPOSITO\n"
  26. +"2.RETIRO\n"
  27. +"3.SALDO\n"
  28. +"4.SALIR\n"));
  29. int nelementos21;
  30. switch(opcion) {
  31. case 1:
  32. valorDeposito= Integer.parseInt(JOptionPane.showInputDialog("Por favor ingrese el valor a depositar"));
  33. if(qDepositos < 4 ) {
  34. if(valorDeposito>=10000) {
  35. depositos[qDepositos] = valorDeposito;
  36. qDepositos = qDepositos +1;
  37. }else {
  38. JOptionPane.showMessageDialog(null,"el valor del deposito debe ser mayor a $9999");
  39.  
  40. }
  41. }else {
  42. JOptionPane.showMessageDialog(null,"La cantidad de depositos fue excedida");
  43. }
  44. saldo=saldo+(valorDeposito*qDepositos);
  45. break;
  46. case 2:
  47. valorRetiros= Integer.parseInt(JOptionPane.showInputDialog("Por favor ingrese el valor a retirar"));
  48. if(qRetiros < 4 ) {
  49.  
  50. if(valorRetiros>=10000) {
  51. retiros[qRetiros] = valorRetiros;
  52. qRetiros ++;
  53. }else {
  54. JOptionPane.showMessageDialog(null,"el valor del retiro debe ser mayor a $9999");
  55.  
  56. }
  57. }else {
  58. JOptionPane.showMessageDialog(null,"La cantidad de retiros fue excedida");
  59. }
  60. saldo=saldo-(valorRetiros*qRetiros);
  61. break;
  62. case 3:
  63. int totalRetiros = 0, totalDepositos=0;
  64. totalRetiros= retiros[0] + retiros[1] + retiros[2];
  65. totalDepositos= depositos[0] + depositos[1] + depositos[2];
  66. JOptionPane.showMessageDialog(null,"El saldo es: " +saldo);
  67. break;
  68. case 4:
  69. nelementos1=totalretiros;
  70. arreglo= new float[nelementos1];
  71. for (int totalRetiros1=0;totalRetiros1<nelementos1;totalRetiros1++) {
  72. arreglo[totalRetiros1] =entrada.nextInt();
  73. }
  74. for (int totalRetiros1=0;totalRetiros1<nelementos1;totalRetiros1++) {
  75. for (int j=0;j<nelementos1;j++) {
  76. if(arreglo[j]>arreglo[j+1]) {
  77. aux=arreglo[j];
  78. arreglo[j]=arreglo[j+1];
  79. arreglo[j+1]=aux;
  80.  
  81. }
  82. }
  83. }
  84. for (int totalRetiros1=0;totalRetiros1<nelementos1;totalRetiros1++) {
  85. JOptionPane.showMessageDialog(null,"los retiros realizados en forma creciente son:" +arreglo[totalRetiros1]);
  86. }
  87.  
  88. nelementos21=totaldepositos;
  89. arreglo= new float[nelementos2];
  90. for (int totalDepositos1=0;totalDepositos1<nelementos2;totalDepositos1++) {
  91. arreglo[totalDepositos1] =entrada.nextInt();
  92. }
  93. for (int totalDepositos1=0;totalDepositos1<nelementos2;totalDepositos1++) {
  94. for (int j=0;j<nelementos2;j++) {
  95. if(arreglo[j]>arreglo[j+1]) {
  96. aux=arreglo[j];
  97. arreglo[j]=arreglo[j+1];
  98. arreglo[j+1]=aux;
  99.  
  100. }
  101. }
  102. }
  103. for (int totalDepositos1=(nelementos2-1);totalDepositos1>=0;totalDepositos1--) {
  104. JOptionPane.showMessageDialog(null,"los depositos realizados en forma decreciente son:" +arreglo[totalDepositos1]);
  105. }
  106. int totalDepositos1 = 0;
  107.  
  108.  
  109.  
  110.  
  111. JOptionPane.showMessageDialog(null,"el nombre del cliente es:\n"
  112. +nombreCliente);
  113. JOptionPane.showMessageDialog(null,"el tipo de cuenta es:\n"
  114. +tipoCuenta);
  115. JOptionPane.showMessageDialog(null,"el saldpo es de:\n"
  116. +saldo);
  117. JOptionPane.showMessageDialog(null,"el total de retiros es de:\n"
  118. +qRetiros);
  119. JOptionPane.showMessageDialog(null,"los retiros de forma creciente son:\n"
  120. +arreglo[valorRetiros]);
  121.  
  122. JOptionPane.showMessageDialog(null,"los depositos de forma decreciente son:\\n"
  123. +arreglo[totalDepositos1]);
  124. break;
  125. default:
  126. JOptionPane.showMessageDialog(null,"opcion incorrecta, digita una opcion entre el 1 y 4");
  127.  
  128. }
  129. }
  130. while (opcion !=4);
  131. }
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement