Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid prompt after Creating an Account #8

Open
flexycode opened this issue Mar 5, 2024 · 2 comments
Open

Invalid prompt after Creating an Account #8

flexycode opened this issue Mar 5, 2024 · 2 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@flexycode
Copy link
Owner

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.

@flexycode flexycode added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels Mar 5, 2024
@flexycode flexycode self-assigned this Mar 5, 2024
@IYB-Mata
Copy link
Contributor

IYB-Mata commented Mar 5, 2024

// 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
Copy link
Owner Author

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. 🌱

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants