Advertisement
robeeeert

cuenta

May 19th, 2023
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.58 KB | None | 0 0
  1. /*
  2.  * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
  3.  */
  4.  
  5. package com.mycompany.validarcuenta;
  6.  
  7. /**
  8.  *
  9.  * @author ianto
  10.  */
  11. import java.util.*;
  12. public class ValidarCuenta {
  13.  
  14.     public static void main(String[] args) {
  15.         boolean validarNumeroC;
  16.         String NumeroCuenta = "";
  17.         Scanner entrada = new Scanner (System.in);
  18.         System.out.println("Ingrese su número de cuenta");
  19.         NumeroCuenta = entrada.nextLine();
  20.         validarNumeroC = validarNumeroCuenta(NumeroCuenta);
  21.         while(!validarNumeroC){
  22.             System.out.println("Número de cuenta no valido");
  23.             System.out.println("Ingrese nuevamente el número de cuenta");
  24.             NumeroCuenta = entrada.nextLine();
  25.             validarNumeroC = validarNumeroCuenta(NumeroCuenta);
  26.         }
  27.         System.out.println("Número de cuenta ingresado correctamente");
  28.  
  29.     }
  30.     public static boolean validarNumeroCuenta(String NumeroCuenta){
  31.         int contador = 0;
  32.         boolean cuentaValida = false;
  33.         if(NumeroCuenta.length() == 28){
  34.             for(int i = 0; i<NumeroCuenta.length(); i++){
  35.                 if( i == 0){
  36.                     switch(NumeroCuenta.charAt(i)){
  37.                         case 'G':
  38.                             contador ++;
  39.                             break;  
  40.                     }
  41.                 }
  42.                 if(i == 1){
  43.                     switch(NumeroCuenta.charAt(i)){
  44.                         case 'T':
  45.                             contador ++;
  46.                             break;  
  47.                     }
  48.                 }
  49.                 switch(i){
  50.                     case 2: case 3:
  51.                         switch(NumeroCuenta.charAt(i)){
  52.                             case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
  53.                                 contador ++;
  54.                                 break;
  55.                         }
  56.                         break;
  57.                     case 4: case 5: case 6: case 7:
  58.                         switch(NumeroCuenta.charAt(i)){
  59.                             case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
  60.                                 contador ++;
  61.                                 break;
  62.                         }
  63.                         break;
  64.                     case 8:
  65.                         switch(NumeroCuenta.charAt(i)){
  66.                             case '0':
  67.                                 contador ++;
  68.                                 break;
  69.                         }
  70.                         break;
  71.                     case 9:
  72.                         switch(NumeroCuenta.charAt(i)){
  73.                             case '1': case '2':
  74.                                 contador ++;
  75.                                 break;
  76.                         }
  77.                         break;
  78.                     case 10:
  79.                         switch(NumeroCuenta.charAt(i)){
  80.                             case '0':
  81.                                 contador ++;
  82.                                 break;
  83.                         }
  84.                         break;
  85.                     case 11:
  86.                         switch(NumeroCuenta.charAt(i)){
  87.                             case '1': case '2':
  88.                                 contador ++;
  89.                                 break;
  90.                         }
  91.                         break;
  92.                     case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27:
  93.                         switch(NumeroCuenta.charAt(i)){
  94.                             case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
  95.                             case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
  96.                                 contador ++;
  97.                                 break;
  98.                         }
  99.                         break;
  100.                 }  
  101.             }
  102.         }
  103.         if(contador == NumeroCuenta.length()){
  104.             cuentaValida = true;          
  105.         }
  106.      return cuentaValida;  
  107.     }
  108. }
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement