aspose file tools*
The moose likes Beginning Java and the fly likes Constructors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Constructors" Watch "Constructors" New topic
Author

Constructors

Jane kamau
Greenhorn

Joined: Jul 08, 2012
Posts: 4
The following codepackage Accountcredit;
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Jane,
Welcome to CodeRanch! I've added code tags to make your post easier to read.

I don't see the question though; just a block of code. Do note that in Java, classnames are camelcase by convention so accountcredit should be AccountCredit.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4392
    
    8

Like Jeanne, I'm not quite sure what you're asking. But take a closer look at your credit() method:
Are you really sure that it's the amount variable that you want to be updating?
Jane kamau
Greenhorn

Joined: Jul 08, 2012
Posts: 4
Thanks for the reply.My question is when I run the code the method credit is never called.The method credit is supposed to add the new amount that the user enters to the initial balance, but in my case it does'nt.This it what I get when I run it.

Account1 balance:$0.00
Account1 balance:$20.00
Enter deposit for account1: 90

adding 90.00 to account1 balance

account1 balance: 0.00
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4392
    
    8

How do you know it's never being called? One way of checking would be to add a print statement. But I'm not convinced that's the problem. I think the problem is that the credit() method doesn't actually do anything, which is what my previous point was referring to.
Jane kamau
Greenhorn

Joined: Jul 08, 2012
Posts: 4
Thats my point, why does it not do anything yet its supposed to.If you look at the method it is supposed to take the deposit amount and add it to the initial balance.This where I need help because I don't see anything wrong with the method credit.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Jane kamau wrote:If you look at the method it is supposed to take the deposit amount and add it to the initial balance.

how do you say the amount is added to balance *in the code*?
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

you have flipped the package, class naming conventions
Jane kamau
Greenhorn

Joined: Jul 08, 2012
Posts: 4
Thanks guys I have figured out where my error was and I have corrected it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Constructors