Home > Net >  I am unsure of why my code is resulting in an Exception in thread "main" java.util.NoSuchE
I am unsure of why my code is resulting in an Exception in thread "main" java.util.NoSuchE

Time:02-10

Query by loan ID

// Method that allows the user to query by loan ID

public static void QuerybyloanID(List<Loan> data) {
    try (Scanner entry = new Scanner(System.in)) {
        System.out.print("Please, enter the loan ID: ");
        String userentry = entry.next();

// For loop is used to locate the loan ID within the list of loans

        for (int i = 0; i < data.size(); i  ) {
            String loanID = data.get(i).getLoanID();
            
            if (loanID.equals(userentry)) {
                boolean pass = true;
                String loanPassword = data.get(i).getPasscode();

                // Three possible character from the loan password
                int one;
                int two;
                int three;

                int [] randomCharacters = randomUniqueGenerator(3, loanPassword.length());
                
                one = randomCharacters[0];
                two = randomCharacters[1];
                three = randomCharacters[2];

// Check to see if the random numbers are the same or different. -> Implement a Hash Map.

                char entry_one = loanPassword.charAt(one);
                char entry_two = loanPassword.charAt(two);
                char entry_three = loanPassword.charAt(three);

                String entry_one_modify = Character.toString(entry_one);
                String entry_two_modify = Character.toString(entry_two);
                String entry_three_modify = Character.toString(entry_three);

                String [] entriesmain = {entry_one_modify, entry_two_modify, entry_three_modify};
                
                try (Scanner entrytwo = new Scanner(System.in)) {
                    for (int k = 0; k < 3; k   ) {
                        System.out.print("Enter character "   randomCharacters[k]   " of the loan pass code: ");
                        String userentrytwo = entrytwo.next();
                        entrytwo.nextLine();

                        if (userentrytwo.equals(entriesmain[k])) {
                            continue;
                        } else {
                            pass = false;
                            continue;
                        }
                    }
                }
                

// Check to see if pass is true or false then take the appropriate action

                if (pass) {
                    System.out.println("Customer Name: "   data.get(i).getFirstName()   " "   data.get(i).getLastName());
                    System.out.println("Branch Code: "   data.get(i).getBrachCode());
                    System.out.println("Gender: "   data.get(i).getGender());
                    System.out.println("Date of Birth: "   data.get(i).getDOB());
                    System.out.println("Loan Amount: "   data.get(i).getLoanAmount());
                    System.out.println("Customer Phone Number: "   data.get(i).getPhoneNumber());
                    MainMenu.options();
                } else { 
                    System.out.println("Wrong Passcode !"); 
                    MainMenu.options();
                } 


            }

CodePudding user response:

  •  Tags:  
  • Related