1 Replies - 450 Views - Last Post: 16 April 2015 - 08:14 PM Rate Topic: -----

#1 12127306   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-March 15

HELP with my code

Posted 16 April 2015 - 08:06 PM

I'm a beginner in JAVA. There is something wrong with my code. When I test following simple code, I get an error when I compile it. In method setAccountnumber(int newAccountnumber), the error says ( can't find symbol - variable newAccountnumber ). I don't understand where is wrong. It's weird because it's a sample code from my college. All other parts are running fine, I get set accountName, getBalance, input deposit amount. But the accountNumber part, when I run getAccountNumber(), I can only get a return 0.


public class BankAccountStaticVersion
{
    /**
     * instance Variables, sometimes classed "fields"
     * or "private data members"
     */
    
    private static int accountNumber = 0;
    private static String accountName = "no name";
    private static double balance = 0.0; // e.g. 1.27 means $1.27
    private static double interestRate = 0.0;
   
    /**
     * @param newAccountNumber The new number for the account
     * /
     
      public static void setAccountnumber(int newAccountnumber)
      {
      accountNumber = newAccountNumber;
      }
     
    /**
     * @return   The account number
     */
    public static int getAccountNumber()
    {
        return accountNumber;
    }
    
    /**
     * @return   The account balance
     */
    public static double getBalance()
    {
        return balance;
    }
    
    /**
     * @param    amount To be added to the balance
     */
    public static void deposit(double amount)
    {
        balance = balance + amount;
    }
    
    /**
     * @param amount to be subtracted from the balance
     * 
     * @return to updated account balance
     */
    public static double withdraw(double amount)
    {
        balance = balance - amount;
        return balance;
    }
    
    /**
     * @param newName The new name for the acocunt
     */
    public static void setAccountName(String newName)
    {
        accountName = newName;
    }
    
    /**
     * @return   The name for the account
     */
    public static String getAccountName()
    {
        return accountName;
    }
    
    /**
     * @param    newInterestRate   New interest rate
     */
    public static void setInterestRate(double newInterestRate)
    {
        interestRate = newInterestRate;
    }
    
    /**
     * @return    The interest rate
     */
    public static double getInterestRate()
    {
        return interestRate;
    }
}  // class BankAccount ( static version )

This post has been edited by modi123_1: 16 April 2015 - 08:12 PM
Reason for edit:: please use the code tag button in the editor


Is This A Good Question/Topic? 0
  • +

Replies To: HELP with my code

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 16479
  • View blog
  • Posts: 65,313
  • Joined: 12-June 08

Re: HELP with my code

Posted 16 April 2015 - 08:14 PM

Java is case sensitive. If your variable happens to be in a different casing than when you use it that error will fly up.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1