Results 1 to 3 of 3
  1. #1
    anthonym2121 is offline Member
    Join Date
    Apr 2009
    Posts
    17
    Rep Power
    0

    Exclamation [SOLVED] Array element not found!

    In this program I can compile it and run it fine except for the fact that when I want to make changes it only makes changes to whatever is in parallelArray[0]

    Here is the link to the code:
    lin(dot)cr/hwx

    I can create an account just fine, it's just when I deposit money into the second,third,fourth,etc. account.

    My output looks like this from the code(I just used random names):

    * You selected: Create Account
    Yksfjdkl, Afjhsdjfh
    Account Number: A4326-YA-3206-KF-66572424 created!
    Account Balance: $0.0
    Credit Limit: $100.0
    * You selected: Create Account
    Gks;dfk, Hdfsljhkl
    Account Number: A4326-GH-8944-KD-47386522 created!
    Account Balance: $0.0
    Credit Limit: $100.0
    * You selected: Deposit
    DEBUG: *A4326-YA-3206-KF-66572424* == *A4326-YA-3206-KF-66572424* is true

    DEBUG: found!!!

    Account to deposit to: A4326-YA-3206-KF-66572424
    Amount to deposit: 600.0

    600.0 deposited to: A4326-YA-3206-KF-66572424
    * You selected: Deposit
    DEBUG: *A4326-GH-8944-KD-47386522* == *A4326-YA-3206-KF-66572424* is false
    DEBUG: *A4326-GH-8944-KD-47386522* == ** is false
    DEBUG: *A4326-GH-8944-KD-47386522* == ** is false
    DEBUG: *A4326-GH-8944-KD-47386522* == *null* is false

  2. #2
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

    Default

    problem seems use repeatedly use "i" in the function
    ...
    Java Code:
    accountNumber[i] = "";
    found in beginning of for loop, if you make deposit to account 0, i set to 0,
    for next loop, accountNumber[i] reset to ""....

    program logic... i think initialization should do first...
    for operation... while loop use instead of for loop...
    because... i think i can make deposit to the same account more than 1000 times...
    Last edited by mtyoung; 04-07-2009 at 05:52 AM.

  3. #3
    anthonym2121 is offline Member
    Join Date
    Apr 2009
    Posts
    17
    Rep Power
    0

    Default

    Quote Originally Posted by mtyoung View Post
    problem seems use repeatedly use "i" in the function
    ...
    Java Code:
    accountNumber[i] = "";
    found in beginning of for loop, if you make deposit to account 0, i set to 0,
    for next loop, accountNumber[i] reset to ""....

    program logic... i think initialization should do first...
    for operation... while loop use instead of for loop...
    because... i think i can make deposit to the same account more than 1000 times...
    I fixed it although there is one problem and that is when the user
    tries to withdraw more money than whats in the account, it goes into negative and I just want it to go to 0.


    lin.cr/hx8

Similar Threads

  1. [SOLVED] indexing an element in an array help!
    By anthonym2121 in forum New To Java
    Replies: 1
    Last Post: 04-03-2009, 07:21 PM
  2. Replies: 1
    Last Post: 03-31-2009, 07:40 AM
  3. adding list to an array element
    By Preethi in forum New To Java
    Replies: 5
    Last Post: 09-25-2008, 05:23 AM
  4. Unique element in an array
    By revathi17 in forum New To Java
    Replies: 2
    Last Post: 12-31-2007, 09:44 AM
  5. Max element in an Array
    By mew in forum New To Java
    Replies: 5
    Last Post: 12-03-2007, 06:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •