• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Help bank account assignment

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys,

Need help with a bank account homework. Its not showing me the amount I deposit when I create the account for option 1 and 2 nor when I deposit it with option 3. Also, its not letting me show the interest rate for option 5 and 9. Have been trying to figure it out and so far, no success.

Any help would be appreciated

Thanks!

Here is the bank menu



This is the bank account class:

 
Ranch Hand
Posts: 258
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess what you mean by "not showing" referring to "showing wrong".
i.e. Even you deposit some money to an account, you print the account balance and showing zero.

If this is what you meant, because you have create a new account on line 68 on every choice.
 
benito kamelas
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the quick reply and correction. The reason i put line 68 outside of the option 1 IF statement is because it was not giving me a main java.lang.NullPointerException. When I put it outside of the IF statement, it does not give me that error but at the same time, it does show me the issues I mentioned earlier.
 
Raymond Tong
Ranch Hand
Posts: 258
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code didn't throw exception doesn't mean it's correct.
Do you need to create an account in all choices or only for certain choices?
 
benito kamelas
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Option 1 creates the account

Option 2 Uses the account created and adds starting balance and starting interest rate

Option 3 Makes the deposit to the account created

Option 4 Makes a withdrawal from the account created

Option 5 Calculates the monthly interest

Option 6 Lets you view users account balance

Option 7 Shows next available account

Option 8 Updates current interest rate to a new one

Option 9 prints your whole account info (current balance and current interest rate)

 
Raymond Tong
Ranch Hand
Posts: 258
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you think all options need to create an account?
This seems to be different to what the requirement asked.

Imagine you going to deposit money in real life, do you deposit to your created account OR a new account?
 
benito kamelas
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Raymond Tong wrote:So you think all options need to create an account?
This seems to be different to what the requirement asked.

Imagine you going to deposit money in real life, do you deposit to your created account OR a new account?



All of the options are linked to option 1 because when you create a new account, the deposit and withdrawal will occur to the new account you just created. If you create another new account from option 1, it will happen the same thing.
 
Raymond Tong
Ranch Hand
Posts: 258
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

benito kamelas wrote:
All of the options are linked to option 1 because when you create a new account, the deposit and withdrawal will occur to the new account you just created. If you create another new account from option 1, it will happen the same thing.


So, that mean you need to create an account only from option 1 but not the others.
But your code is creating an account for all options now.
 
benito kamelas
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Raymond Tong wrote:

benito kamelas wrote:
All of the options are linked to option 1 because when you create a new account, the deposit and withdrawal will occur to the new account you just created. If you create another new account from option 1, it will happen the same thing.


So, that mean you need to create an account only from option 1 but not the others.
But your code is creating an account for all options now.



Ok, so how can I fix that without having the null exception error?
 
Raymond Tong
Ranch Hand
Posts: 258
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
NullPointerException throws when it is referring to an object with value assigned to NULL.
So, if you assign the object with some value, it wouldn't throw Exception.
Think about what object may be NULL and what value should be assigned and when should that happened.

Drawing a flow diagram may help yourself.
 
reply
    Bookmark Topic Watch Topic
  • New Topic