Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cajeroautomatico;
- import javax.swing.JOptionPane;
- import java.util.Scanner;
- public class cajero {
- public static void main (String[]args) {
- Scanner entrada=new Scanner(System.in);
- int retiros[], depositos[], auxDepositos, auxRetiros, opcion, qRetiros=0, qDepositos=0, valorRetiros = 0, valorDeposito;
- float aux;
- String nombreCliente, tipoCuenta;
- int totalretiros = 0, total;
- float arreglo[];
- float saldo, saldod=0, saldor = 0;
- int nelementos1=totalretiros;
- int totaldepositos = 0;
- int nelementos2=totaldepositos;
- depositos = new int [3];
- retiros = new int [3];
- nombreCliente =JOptionPane.showInputDialog("Por favor digite su nombre");
- tipoCuenta =JOptionPane.showInputDialog("Por favor digite el tipo de cuenta");
- saldo =Float.parseFloat(JOptionPane.showInputDialog("Por favor ingrese el saldo inicial"));
- do {
- opcion = Integer.parseInt(JOptionPane.showInputDialog("Seleccione una opción: \n"
- +"1.DEPOSITO\n"
- +"2.RETIRO\n"
- +"3.SALDO\n"
- +"4.SALIR\n"));
- int nelementos21;
- switch(opcion) {
- case 1:
- valorDeposito= Integer.parseInt(JOptionPane.showInputDialog("Por favor ingrese el valor a depositar"));
- if(qDepositos < 4 ) {
- if(valorDeposito>=10000) {
- depositos[qDepositos] = valorDeposito;
- qDepositos = qDepositos +1;
- }else {
- JOptionPane.showMessageDialog(null,"el valor del deposito debe ser mayor a $9999");
- }
- }else {
- JOptionPane.showMessageDialog(null,"La cantidad de depositos fue excedida");
- }
- saldo=saldo+(valorDeposito*qDepositos);
- break;
- case 2:
- valorRetiros= Integer.parseInt(JOptionPane.showInputDialog("Por favor ingrese el valor a retirar"));
- if(qRetiros < 4 ) {
- if(valorRetiros>=10000) {
- retiros[qRetiros] = valorRetiros;
- qRetiros ++;
- }else {
- JOptionPane.showMessageDialog(null,"el valor del retiro debe ser mayor a $9999");
- }
- }else {
- JOptionPane.showMessageDialog(null,"La cantidad de retiros fue excedida");
- }
- saldo=saldo-(valorRetiros*qRetiros);
- break;
- case 3:
- int totalRetiros = 0, totalDepositos=0;
- totalRetiros= retiros[0] + retiros[1] + retiros[2];
- totalDepositos= depositos[0] + depositos[1] + depositos[2];
- JOptionPane.showMessageDialog(null,"El saldo es: " +saldo);
- break;
- case 4:
- nelementos1=totalretiros;
- arreglo= new float[nelementos1];
- for (int totalRetiros1=0;totalRetiros1<nelementos1;totalRetiros1++) {
- arreglo[totalRetiros1] =entrada.nextInt();
- }
- for (int totalRetiros1=0;totalRetiros1<nelementos1;totalRetiros1++) {
- for (int j=0;j<nelementos1;j++) {
- if(arreglo[j]>arreglo[j+1]) {
- aux=arreglo[j];
- arreglo[j]=arreglo[j+1];
- arreglo[j+1]=aux;
- }
- }
- }
- for (int totalRetiros1=0;totalRetiros1<nelementos1;totalRetiros1++) {
- JOptionPane.showMessageDialog(null,"los retiros realizados en forma creciente son:" +arreglo[totalRetiros1]);
- }
- nelementos21=totaldepositos;
- arreglo= new float[nelementos2];
- for (int totalDepositos1=0;totalDepositos1<nelementos2;totalDepositos1++) {
- arreglo[totalDepositos1] =entrada.nextInt();
- }
- for (int totalDepositos1=0;totalDepositos1<nelementos2;totalDepositos1++) {
- for (int j=0;j<nelementos2;j++) {
- if(arreglo[j]>arreglo[j+1]) {
- aux=arreglo[j];
- arreglo[j]=arreglo[j+1];
- arreglo[j+1]=aux;
- }
- }
- }
- for (int totalDepositos1=(nelementos2-1);totalDepositos1>=0;totalDepositos1--) {
- JOptionPane.showMessageDialog(null,"los depositos realizados en forma decreciente son:" +arreglo[totalDepositos1]);
- }
- int totalDepositos1 = 0;
- JOptionPane.showMessageDialog(null,"el nombre del cliente es:\n"
- +nombreCliente);
- JOptionPane.showMessageDialog(null,"el tipo de cuenta es:\n"
- +tipoCuenta);
- JOptionPane.showMessageDialog(null,"el saldpo es de:\n"
- +saldo);
- JOptionPane.showMessageDialog(null,"el total de retiros es de:\n"
- +qRetiros);
- JOptionPane.showMessageDialog(null,"los retiros de forma creciente son:\n"
- +arreglo[valorRetiros]);
- JOptionPane.showMessageDialog(null,"los depositos de forma decreciente son:\\n"
- +arreglo[totalDepositos1]);
- break;
- default:
- JOptionPane.showMessageDialog(null,"opcion incorrecta, digita una opcion entre el 1 y 4");
- }
- }
- while (opcion !=4);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement