Results 1 to 6 of 6

Thread: Java code to manage book accounts

  1. #1
    Join Date
    Dec 2009
    Posts
    204

    Java code to manage book accounts

    Hello,
    I need a small program in java allows AUI to manage a bank account that is the small deposit-withdrawal-pay. I have been trying this for a long time now , but I have not found rather I have not completed even the half way, os if you have nay ideas regarding this code, then please help me I am the interested on here. thanks in advance.

  2. #2
    Join Date
    Nov 2009
    Posts
    333

    Re: Java code to manage book accounts

    Hello,
    Try the following code, this may help you
    Code:
    Public class account
    {
    private float bal;
    private static float numcp =0;
    / / numcp is initialized to zero, it is common to all classes and for each instantiation it will change in value since it is incremented.
     
    Public account()
    {numcp + +;}
    / / The first account will be number 1
    / / default bal will be initialized to zero.
     
    Public void credit(float amount)
    {bal + = amount;}
     
    Public void charge(float amount)
    {bal-= amount;}
     
    Public float getSolde()
    {return(bal);}
    / / accessor method for reading 
     
    Public void display()
    {System.out.System.out.println("account number"+ + numcp"The bal is"+ bal +"Dinars");}}
    
    Public class TestBanque
    {Public static void hand (String [] args)
    	{Account acc =new account();
    / / Instance 1 will account number 1 and a bal of 0.
    	acc.credit(1000);
    acc.dbitrate(500);
    acc.display();
                  account = acc2 new account();
    / / instance 2 will have the account number 2 and a bal of 0.
    
    acc2.credit(5000);
    acc2.dbitrate(250);
    acc2.display();
    	}
    }

  3. #3
    Join Date
    Nov 2009
    Posts
    335

    Re: Java code to manage book accounts

    Hello,
    I do not understand your use of the static attribute comprises. Each account to account number 1 (as a primary key in a table) each instance of the class Account is a complete. If I instantiate the class twice, I find myself with two accounts with different balances and account number the same? I hope you are doing the correct things in your code. Best of Luck

  4. #4
    Join Date
    Nov 2009
    Posts
    356

    Re: Java code to manage book accounts

    Hello,
    I think you are doing something wrong here , that is this part of the program
    Code:
    private static float nmcmp =0;
    / / nmcmp is initialized to zero, it is common to all classes and for each instantiation it will change in value since it is incremented.
     
    Public account()
    {nmcmp + +;}
    I think you will need a alternative for this part of the code, I have no idea right now but when I will have one I will let you know about it.

  5. #5
    Join Date
    Nov 2009
    Posts
    330

    Re: Java code to manage book accounts

    Hello,
    Even I think that something is missing in the code
    For example
    Account 1: pay 15 d
    Account 2: pay 25 d
    Suppose I call my method display () the first object is not connects the program back to it.
    Code:
    Account number two The balance is 15 d
    I think the logic is somewhere wrong in the problem. I have not found a replacement yet, but I will try to find one. Still, then you work on it.

  6. #6
    Join Date
    Nov 2009
    Posts
    446

    Re: Java code to manage book accounts

    Hello,
    That was just to have it in future responses more quickly is not easy to get an immediate answer on some work that has been started, but good for this example is easy
    To answer your question is, the display will be:
    Code:
    Account number 1 The balance is 450 d.
    the Account number 2 The balance is 4645 d.
    This is initialized to 0 and at each instantiation it will be incremented, so the object 1 will be the number 1, it also uses this method to determine the number of instantiation has been done.

Similar Threads

  1. How to manage and maintain WD My Book Live 2TB Drive
    By Thedevotee in forum Hardware Peripherals
    Replies: 6
    Last Post: 27-03-2012, 05:52 PM
  2. Replies: 1
    Last Post: 22-05-2011, 03:41 AM
  3. Replies: 4
    Last Post: 17-08-2010, 12:20 AM
  4. How to manage user accounts in Windows Home Server?
    By Zhankana_n in forum Operating Systems
    Replies: 5
    Last Post: 05-02-2010, 11:13 AM
  5. Manage two Google Accounts in same browser
    By Calvin K in forum Technology & Internet
    Replies: 3
    Last Post: 08-12-2009, 10:25 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,991,141.40783 seconds with 16 queries