Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-07-2007, 12:06 AM
Member
 
Join Date: Nov 2007
Posts: 36
dirtycash is on a distinguished road
error in code
Quote:

The deposit command allows a user to deposit money into an existing account.
The cashier must ask for the email address of the account, the password and the
amount to be deposited. If the password is correct, the money will be deposited into
the account. If the deposit could not be completed, the cashier prints out a message
informing the user. If the deposit is completed successfully, the cashier responds
with “Thank you for using the bank”.
Code:
private void makeDeposit(InputReader reader) { String email = reader.getText("enter email address: "); String password = reader.getText("enter password: "); int amount = reader.getNumber("enter deposit amount: "); if(accounts.containsKey(email)) { Account account = (Account)accounts.get(email); if(account.getPassword().equals(password)) { boolean success = account.deposit(amount); if(success) System.out.println("Thank you for using the bank"); else System.out.println("Unable to deposit to your account"); } } }
it doesn't come up with the print messages whilst testing it
can anyone see where its gone wrong?

thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-07-2007, 01:07 AM
ShoeNinja's Avatar
Senior Member
 
Join Date: Oct 2007
Posts: 123
ShoeNinja is on a distinguished road
Send a message via AIM to ShoeNinja
If neither the 'thank you' nor 'unable to deposit' String are printing then it has to be something with the other two ifs. Double check that you are entering valid email and password data.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-07-2007, 01:40 AM
Senior Member
 
Join Date: Nov 2007
Location: Newport, WA
Posts: 141
staykovmarin is on a distinguished road
It always help to print out the data when debugging (or using a debugger) to see what the computer is doing with the data. You might think you are typing in the right email, but it might not be contained in the accounts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with code (static error) oceansdepth New To Java 1 03-28-2008 06:32 AM
I need help fixing my code.. or non code? MrHuggykins New To Java 1 03-20-2008 12:12 AM
Pls help with a code error. saytri New To Java 8 12-24-2007 10:10 PM
error stack when I try to execute my code paty New To Java 1 08-02-2007 10:32 PM
Generating Code Automatically Using Custom code Template In Eclipse JavaForums Eclipse 1 04-26-2007 05:52 PM


All times are GMT +3. The time now is 04:35 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org