flexycode / CCPRGG1L_ACTIVITY_COM23P

CCPRGG1L-COMP23P Group Project for 1st semester final exam project, Exercises and Lab Activity for Professor Jay Abaleta
6 stars 4 forks source link

Invalid prompt after Creating an Account #8

Open flexycode opened 7 months ago

flexycode commented 7 months ago

Kindly fix some slight bug / error of the function. Particularly in lines of code in 60-66, and 10

Everytme I select 1 and successfully create the account.

It always prompting that the "Account created successfully. Your account number is 1"

But the counting is always starting in 0 whenever I select the windraw, deposit and display account.

IYB-Mata commented 7 months ago

// CASE 1: Creating new account private static void createNewAccount(Scanner scanner) { if (accountCount >= MAX_ACCOUNTS) { System.out.println("Maximum account limit reached."); return; }

    System.out.print("Enter Account Name: ");
    String accountName = scanner.next();

    accountNames[accountCount] = accountName;
    accountNumbers[accountCount] = accountCount;
    balances[accountCount] = 0.0;

    System.out.println("Account created successfully. Your account number is: " + accountCount);
    accountCount++; // By moving the incrementation syntax after the display will now align with array indices, starting from 0.
}

Sorry nakalimutan ko yung tinuro mo sakin mag pull req pag sa web lang.

flexycode commented 7 months ago

My final rendition regarding on this issue. Previously, before I post this issue. I also come up with my own solution without using incrementation syntax, but I am not satisfied with my input. So I decide to seek some help with you guys. So here's the solution for this project.

🔭 Gab Revision Code solution

  private static void createNewAccount(Scanner scanner) {
        if (accountCount >= MAX_ACCOUNTS) {
            System.out.println("Maximum account limit reached.");
            return;
        }

        System.out.print("Enter Account Name: ");
        String accountName = scanner.next();

        accountNames[accountCount] = accountName;
        accountNumbers[accountCount] = accountCount;
        balances[accountCount] = 0.0;
        accountCount++;

        System.out.println("Account created successfully. Your account number is: " + accountCount);
        accountCount++;
    }

📫 My previous solution

    private static void createNewAccount(Scanner scanner) {
        if (accountCount >= MAX_ACCOUNTS) {
            System.out.println("Maximum account limit reached.");
            return;
        }

        System.out.print("Enter Account Name: ");
        String accountName = scanner.next();

        accountNames[accountCount] = accountName;
        accountNumbers[accountCount] = accountCount - 1; // Assign the current accountCount - 1 as the account number
        balances[accountCount] = 0.0;
        accountCount++;

        System.out.println("Account created successfully. Your account number is: " + (accountCount - 1));
    }

🤔 Final decision

We will push Gab's solution to the main repository, so we can move forward to our project and submit it this week. 🌱