Results 1 to 12 of 12
  1. #1
    alex067 is offline Member
    Join Date
    Sep 2012
    Posts
    6
    Rep Power
    0

    Default Checking Account function, need help!

    Hey everyone. For my assignment, I am to construct a program which deals with the users checking account.

    The assignment: Write a class with methods to help you balance your checking account(an object class-main method is not in this class). The CheckingAccount Class should have at least two instance variables: the balance and the total service charges, along with methods to get and set each instance variables. You may add other variables and methods if you like. The program should read the initial balance for the month, followed by a series of transactions. For each transaction entered, the program should display the transaction data, the current balance for the account, and the total service charges. Service charges are $0.10 for a deposit and $0.15 for a check. If the balance drops below $500.00 at any point during the month, a service charge of $5.00 is assessed once for the month. Anytime the balance drops below $50.00, the program should print a warning message. If the balance becomes negative, an additional service charge of $10.00 should be assessed for each check until the balance becomes positive again. A transaction takes the form of an int number, followed by a double number. If the int number is a 1, then the double number is the amount of a check. If the int number is 2, then the double number is the amount of a deposit. The last transaction is 0 with no number to follow it.
    A sample Input/Output dialogue might look like this: (Use the JOptionPane for the dialog)

    The sample code:
    Java Code:
    public class Main
    {
       //global variables:
       //define a CheckingAccount object to keep trach of the
       // account information.
       public static void main (String[] args)
       {
           // defines local variables
           //  get initial balance from the user
           //  perform in a loop until the trans code = 0
           //    get the trans code from the user
                 and process it with appropriate helper method
          //   When loop ends show final balance to user.
       }
      
       public static __________ getTransCode()
       {
       }
       public static _________ getTransAmt()
       {
       }
       public static __________ processCheck(___________)
       {
       }
       public static __________ processDeposit(___________)
       {
       }
     
    }
     
    --------------------CheckingAccount.java -------------------------
     
    public class CheckingAccount
    {
     
          private double balance;
          private double totalServiceCharge;
     
          public CheckingAccount(double initialBalance)
          {
                balance = ______________________;
                totalServiceCharge = ______________;
          }
     
          public ____________ getBalance()
          {
                return _______________;
          }
     
          public void setBalance(double transAmt, int tCode)
          {
                if(tCode == 1)
                balance = ___________________;
                else //if(tCode == 2)
                    balance = ______________________;
          }
     
          public ____________ getServiceCharge()
          {
                return totalServiceCharge;
          }
     
            public void setServiceCharge(double currentServiceCharge)
          {
                totalServiceCharge = ___________________________;
          }
    }
    The code I have currently:

    Java Code:
    import javax.swing.JOptionPane;
    public class Assignment1 
    {
           
            
            
           public static CheckingAccount info;
           
            
       
         public static void main(String[] args)
        {
           String balance, transcode, transamount, input;
           
           CheckingAccount info;
           
           double ibalance;
           int tcode;
           double tamount;
           
           balance = JOptionPane.showInputDialog ("Enter your initial balance: ");
            ibalance = Double.parseDouble(balance);
            
            info = newCheckingAccount(ibalance);
           
           do
           {
               
            
    
            transcode = JOptionPane.showInputDialog ("Enter your transaction" + 
                       " code:");
            tcode = Integer.parseInt(transcode);
            
            if(tcode == 1)
            {
           
            transamount = JOptionPane.showInputDialog ("Enter your trans amount:");
            tamount = Double.parseDouble(transamount);
            
            CheckingAccount info = new CheckingAccount(tamount, tcode, ibalance);
            
            
            public static int getTransCode()
            {
                int transcode;
                return transcode;
            }
            }
            public static _________ getTransAmt()
            {
            }
            public static __________ processCheck(___________)
            {
            }
            public static __________ processDeposit(___________)
            {
            }
            
            
            
            
        }
    }
    I am having trouble at line 34, which is the info = new CheckingAccount (ibalance); line, an error comes up stating:
    cannot find symbol
    symbol: method newCheckingAccount(double)
    location: class Assignment 1

    I am also unsure how to proceed after asking for the transaction amount, using the checkingaccount.class how do I keep counters on the transaction amount considering the various parameters it presents?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Checking Account function, need help!

    Notice the difference between the line you state you're having a problem with:
    Java Code:
     info = new CheckingAccount (ibalance);
    And the actual line in the code? The error message is telling you exactly what's wrong:

    cannot find symbol
    symbol: method newCheckingAccount(double)

  3. #3
    alex067 is offline Member
    Join Date
    Sep 2012
    Posts
    6
    Rep Power
    0

    Default Re: Checking Account function, need help!

    Yeah the line on the code I posted is wrong for some reason, in my program it states its 34 which is the info = new CheckingAccount line.

    What does that mean, cannot find symbol? I've tried putting double as an argument, but an error comes up saying:

    .class expected
    unexpected type
    required: value
    found: class


    The code for the checkingaccount.class is:

    Java Code:
    public class CheckingAccount 
    {
        private double balance;
        private double totalServiceCharge;
        
        public CheckingAccount(double balance)
        {
            balance = ibalance;
            totalServiceCharge=
        }
        public getBalance()
        {
            return ;
            
        }
        public void setBalance(double transAmt, int tCode)
        {
               if(tCode == 1)
               balance = ;
               else if(tCode == 2)
               balance =;
        }
        
        public getServiceCharge()
        {
            return totalServiceCharge;
        }
        public void setServiceCharge(double currentServiceCharge)
        {
            totalServiceCharge =;
        }
    }
    
        }
        }
    This is more or less the sample code my instructor has provided

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Checking Account function, need help!

    If you've made changes and have a new error, then you need to post the new code and the complete error message. Else you're forcing us to guess, and we're notoriously bad at that.

  5. #5
    alex067 is offline Member
    Join Date
    Sep 2012
    Posts
    6
    Rep Power
    0

    Default Re: Checking Account function, need help!

    Quote Originally Posted by Fubarable View Post
    If you've made changes and have a new error, then you need to post the new code and the complete error message. Else you're forcing us to guess, and we're notoriously bad at that.
    That's the only error I get, there's no other information provided.

    I've only put double as an argument and the error is what I've posted in my previous post. Other then that, that's all the information I've got.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Checking Account function, need help!

    Quote Originally Posted by alex067 View Post
    That's the only error I get, there's no other information provided.

    I've only put double as an argument and the error is what I've posted in my previous post. Other then that, that's all the information I've got.
    You state that you put "double as an argument" that's a change in your code -- *again* if you need our help, please post it as we need to see exactly what you mean by this, and the only way to show it is by showing your code. I'm not sure why you're holding back on this request.
    Last edited by Fubarable; 09-25-2012 at 05:27 AM.

  7. #7
    alex067 is offline Member
    Join Date
    Sep 2012
    Posts
    6
    Rep Power
    0

    Default Re: Checking Account function, need help!

    Yes, I put double as an argument, meaning info = new CheckingAccount(double); but as I've said the only error message I've recieved is
    .class expected
    unexpected type
    required: value
    found: class

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Checking Account function, need help!

    Quote Originally Posted by alex067 View Post
    Yes, I put double as an argument, meaning info = new CheckingAccount(double);
    OK, that's more like it. Don't do that. You need to pass a double variable or double literal into the constructor when calling it. You don't pass in double itself. I was afraid that you might be doing this but couldn't tell until you showed me the code. The solution is simple:
    1) fix the typographical error that you showed in your first post, and it looks like you've done that by separating the identifier "new" from "CheckingAccount", and
    2) don't try to pass in variable type names as if they were variables.

  9. #9
    alex067 is offline Member
    Join Date
    Sep 2012
    Posts
    6
    Rep Power
    0

    Default Re: Checking Account function, need help!

    Quote Originally Posted by Fubarable View Post
    OK, that's more like it. Don't do that. You need to pass a double variable or double literal into the constructor when calling it. You don't pass in double itself. I was afraid that you might be doing this but couldn't tell until you showed me the code. The solution is simple:
    1) fix the typographical error that you showed in your first post, and it looks like you've done that by separating the identifier "new" from "CheckingAccount", and
    2) don't try to pass in variable type names as if they were variables.
    Wow, thank you so much I don't know how I didn't see the error of a simple space congestion. Thank you once again.


    I'm quite lost on how to produce the results, with the transaction fee having a lot of parameters (0.10 cents for a deposit, 0.15 for check, if balance is below 500 then add 5.00).

    When I compile, the program stops at line 9 on the CheckingAccount.java class. How would I construct the totalservicecharge variable with the listed parameters? For the balance variable I put balance = ibalance;

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

    Default Re: Checking Account function, need help!

    Quote Originally Posted by alex067 View Post
    Wow, thank you so much I don't know how I didn't see the error of a simple space congestion. Thank you once again.
    Yep, that's why I highlighted that bit in red (see my first answer).

    I'm quite lost on how to produce the results, with the transaction fee having a lot of parameters (0.10 cents for a deposit, 0.15 for check, if balance is below 500 then add 5.00).

    When I compile, the program stops at line 9 on the CheckingAccount.java class. How would I construct the totalservicecharge variable with the listed parameters? For the balance variable I put balance = ibalance;
    Please tell the details about this.

  11. #11
    alex067 is offline Member
    Join Date
    Sep 2012
    Posts
    6
    Rep Power
    0

    Default Re: Checking Account function, need help!

    Quote Originally Posted by Fubarable View Post
    Yep, that's why I highlighted that bit in red (see my first answer).



    Please tell the details about this.

    After fixing the error, I compiled and the program stopped when the main function calls for info = new CheckingAccount(ibalance);

    It stops at the CheckingAccount.java Class, under method
    Java Code:
     public CheckingAccount(double ibalance)
        {
            balance = ibalance;
            totalServiceCharge= balance+
        }
        public getBalance()
        {
           
            return ;
            
        }
    Where the variable Totalservicecharge has yet to be identified. My question is how I would go about declaring this variable, considering the various parameters it presents. For example, if the users balance is below 500, I am to charge 5.00. For every deposit, I am to charge 0.5 and for every check 0.15

    How would I construct this variable considering it has 3 different parameters to be considered?

  12. #12
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Checking Account function, need help!

    Quote Originally Posted by alex067 View Post
    After fixing the error, I compiled and the program stopped when the main function calls for info = new CheckingAccount(ibalance);

    It stops at the CheckingAccount.java Class, under method
    Java Code:
     public CheckingAccount(double ibalance)
        {
            balance = ibalance;
            totalServiceCharge= balance+
        }
        public getBalance()
        {
           
            return ;
            
        }
    Where the variable Totalservicecharge has yet to be identified. My question is how I would go about declaring this variable, considering the various parameters it presents. For example, if the users balance is below 500, I am to charge 5.00. For every deposit, I am to charge 0.5 and for every check 0.15

    How would I construct this variable considering it has 3 different parameters to be considered?
    First off it's totalServiceCharge, not Totalservicecharge. I know that I'm nitpicking about your post above that's not even part of your code, but since programming is an exercise in precision, you have to develop a strong intolerance for this thing.

    Next off, we must decide on program logic before we can think about how to code things. Above you're talking about what happens when you create a new CheckingAccount. So what will the accumulated service charge be at the time of account creation? That number is what you should initialize the variable to.

Similar Threads

  1. Recursive function to iteractive function
    By mikeZet in forum New To Java
    Replies: 0
    Last Post: 03-13-2012, 02:42 AM
  2. Checking if a math function is valid
    By HardToHandle in forum New To Java
    Replies: 3
    Last Post: 01-18-2012, 02:40 AM
  3. Calling function in Javascript- from other function
    By jdigger in forum New To Java
    Replies: 1
    Last Post: 02-27-2011, 10:00 PM
  4. Transfer from one account to another
    By vividcooper in forum New To Java
    Replies: 3
    Last Post: 01-26-2010, 11:43 PM
  5. Replies: 3
    Last Post: 12-04-2009, 04:08 PM

Posting Permissions

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