Page 1 of 3 123 LastLast
Results 1 to 20 of 55

Thread: Help?

  1. #1
    wdlax11 is offline Member
    Join Date
    Feb 2011
    Posts
    25
    Rep Power
    0

    Exclamation Help?

    Hey guys so I have to do this project but for some reason it says cannot find symbol. Can anyone help?

    Here is the code.

    Java Code:
    /**
     * OverBank is used to tell a person how much money is in their bank account after a widthdraw, or deposit. 
     * 
     * @author 
     * @version 1.0 2/6/2011
     */
    public class BankAccount
    {
       
        /**
         * Constructor for objects of class OverBank
         */
        public BankAccount()
        {
        // instance variable double balance is how much money is curently in the account.
        // instance variable string name is the name of the person owning the account.
        double balance;
        String name;  
    }
    
        /**
         * deposit method returns nothing, accepts a double that is the amount of money being withdrawn.  This will be subtracted to the balance.
         * 
         * @param      double deposit
         * @return     nothing
         */
        public void deposit(double deposit, double current,double balance)
        {
        
            balance = deposit + current;
    
        }
        
         /**
         * withdraw method returns nothing, accepts a double that is the amount of money being withdrawn.  This will be subtracted ded to the balance.
         * 
         * @param      double withdrawn
         * @return     nothing
         */
        public void withdrawn(double withdrawn, double current,double balance)
        {
        
            balance = current - withdrawn;
    
        }
        }

    Main Method The error is down here.
    Java Code:
    /**
     * Tester is the main method of OverBank.  This is where the inputs for money will be asked.
     * 
     * @author 
     * @version 1.0      2/6/2011
     */
    public class Tester
    {
    
        /**
         * MAIN METHOD
         */
       public static void main(String [ ] args)
        {
    [COLOR="DarkOrange"]        double BankAccount;
            BankAccount myAccount = new BankAccount (1000);[/COLOR]
        }
        
    }

    I highlighted where the error occurs. I need to set myAccount to a value of $1000 but when I try to do this it won't let me.

    Moderator Edit: Code tags added
    Last edited by Fubarable; 02-06-2011 at 07:38 PM. Reason: Moderator Edit: Code tags added

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,005
    Blog Entries
    7
    Rep Power
    20

    Default

    You have only defined a constructor that doesn't take arguments; in your main( ... ) method you're trying to use a constructor that takes one argument numeric parameter. You don't have that. That was what the compiler is complaining about.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    wdlax11 is offline Member
    Join Date
    Feb 2011
    Posts
    25
    Rep Power
    0

    Default

    ok well what if i do this?

    /**
    * MAIN METHOD
    */
    public static void main(String [ ] args)
    {
    String BankAccount;
    double myAccount;
    myAccount = 1000;

    deposit(505.22);
    System.out.println(balance);

    would that work?
    or would it not be able to call the deposit method?

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,005
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by wdlax11 View Post
    ok well what if i do this?

    /**
    * MAIN METHOD
    */
    public static void main(String [ ] args)
    {
    String BankAccount;
    double myAccount;
    myAccount = 1000;

    deposit(505.22);
    System.out.println(balance);

    would that work?
    or would it not be able to call the deposit method?
    Have you tried it or are you just guessing and hoping for the best?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    wdlax11 is offline Member
    Join Date
    Feb 2011
    Posts
    25
    Rep Power
    0

    Default

    i have tried it however it takes forever to compile, so I think that it doesn't work? It never says compilation complete nor does it say error.

  6. #6
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    274
    Rep Power
    4

    Default

    What for you need String BankAccount and double myAccount. I can see you never use them...

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,005
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by wdlax11 View Post
    i have tried it however it takes forever to compile, so I think that it doesn't work? It never says compilation complete nor does it say error.
    You should check your installation before you try to develop any code; javac (the Java compiler) is extremely fast and it shouldn't take 'forever' to compile.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    wdlax11 is offline Member
    Join Date
    Feb 2011
    Posts
    25
    Rep Power
    0

    Default

    alright yeah that 2nd way doesn't work. It can't find the method like i thought.

  9. #9
    wdlax11 is offline Member
    Join Date
    Feb 2011
    Posts
    25
    Rep Power
    0

    Default

    so I need to do it along the lines of
    /**
    * MAIN METHOD
    */
    public static void main(String [ ] args)
    {
    double BankAccount;
    BankAccount myAccount = new BankAccount (1000);
    }

    }

    how do I make my constructor accept arguments?

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by wdlax11 View Post
    how do I make my constructor accept arguments?
    Give the BankAccount class a constructor that accepts the arguments needed, but this has already been suggested I see. Have you tried this? If so, what happened?


    Also, when posting code here, please use code tags so that your code will retain its formatting and thus will be readable -- after all, your goal is to get as many people to read your post and understand your code as possible, right?

    To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.

    Another way to do this is to manually place the tags into your code by placing the tag [code] above your pasted code and the tag [/code] below your pasted code like so:

    Java Code:
    [code]
      // your code goes here
      // notice how the top and bottom tags are different
    [/code]
    I will edit your first post but will leave it to you to edit your other posts.

    Luck!

  11. #11
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    274
    Rep Power
    4

    Default

    Java Code:
    public BankAccount(int [I]someNumber[/I]){
    
              // your code for constructor
    }

  12. #12
    wdlax11 is offline Member
    Join Date
    Feb 2011
    Posts
    25
    Rep Power
    0

    Default

    would i place that in the main method or in the constructor?

  13. #13
    wdlax11 is offline Member
    Join Date
    Feb 2011
    Posts
    25
    Rep Power
    0

    Default

    I would place that in the constructor like this?
    Java Code:
    /**
         * Constructor for objects of class BankAccount
         */
        public BankAccount(int x){
       
          double BankAccount;  
        }

    Then in the tester put this?

    Java Code:
     /**
       * MAIN METHOD
       */
       public static void main(String [ ] args)
       {
         int x =1000;
         BankAccount myAccount = new BankAccount (x);
       }

  14. #14
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by wdlax11 View Post
    would i place that in the main method or in the constructor?
    Have you read anything that's been posted?

  15. #15
    wdlax11 is offline Member
    Join Date
    Feb 2011
    Posts
    25
    Rep Power
    0

    Default

    yeah. I just really lost. My teacher really didn't teach us much of this because it's been snowing a lot and we have had a lot of snow days.

  16. #16
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by wdlax11 View Post
    I would place that in the constructor like this?
    Java Code:
    /**
         * Constructor for objects of class BankAccount
         */
        public BankAccount(int x){
       
          double BankAccount;  
        }
    You're not doing anything with "x". Also BankAccount should not be declared as a double inside of the constructor.

  17. #17
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    274
    Rep Power
    4

    Default

    Well, that will be your constructor. I put int as parameter just as an example.

  18. #18
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by wdlax11 View Post
    yeah. I just really lost. My teacher really didn't teach us much of this because it's been snowing a lot and we have had a lot of snow days.
    You should check out the Java tutorials and start going through them. You can't guess at this stuff.

  19. #19
    wdlax11 is offline Member
    Join Date
    Feb 2011
    Posts
    25
    Rep Power
    0

    Default

    Yeah, I'm reading in my book however the thing they are dealing with in the example is a circle, and really isn't helping me much.

    now im getting the error cannot find sumbol - method deposit(double)

  20. #20
    wdlax11 is offline Member
    Join Date
    Feb 2011
    Posts
    25
    Rep Power
    0

    Default

    Java Code:
    int x =1000;
      
         BankAccount myAccount = new BankAccount (x);
         
         deposit(505.22);
         System.out.println(balance);

Page 1 of 3 123 LastLast

Posting Permissions

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