4 Replies - 1048 Views - Last Post: 27 February 2010 - 05:39 PM Rate Topic: -----

#1 bella313  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 27-February 10

Account Class

Posted 27 February 2010 - 05:18 PM

I am getting an error in the AccountTest at account myAccount = new account();
I am not very good at programming so I will appologize ahead of time. Thank You.

 public class AccountTest {
  public static void main(String[] args) {
    
	 account myAccount = new account();
	 myAccount.setId(1122);
	 myAccount.setBalance(20000, 2500, 3000);
	 myAccount.setAnnualInterestRate(.045);
	 
	 System.out.println(myAccount.toString());
	  }
}

public class account {
  
  private int id;
  private double balance;
  private double annualInterestRate;

  private double withdraw;
  private double deposit; 
  private double monthlyInterestRate;
  
   public account() {
    id = 0;
	 balance = 0;
	 annualInterestRate = 0;
  } 

  
 
  public void setId(int i) {
    id = i;
  } 
 
  public int getId() {
    return id;
  }
  
  public void setBalance(double bal, double wd, double dep) {
    balance = bal;
	 withdraw = wd;
	 deposit = dep;
  }
  
  public double getBalance() {
    return balance - withdraw + deposit;
  }
  
  public void setAnnualInterestRate(double air) {
    annualInterestRate = air;
  }
  
  public double getAnnualInterestRate() {
    return annualInterestRate;
  }
  
   
 
  public String toString() {
  String printAccount = "";
  
    printAccount += "For account: " + id +  "\nBalance: " +
	 balance + "\nMonthly Interest Rate: " +
	   monthlyInterestRate;
       
  return printAccount;
 
  }
}




Is This A Good Question/Topic? 0
  • +

Replies To: Account Class

#2 erik.price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 485
  • View blog
  • Posts: 2,690
  • Joined: 18-December 08

Re: Account Class

Posted 27 February 2010 - 05:26 PM

Could you describe what errors you're getting?
Was This Post Helpful? 0
  • +
  • -

#3 bella313  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 27-February 10

Re: Account Class

Posted 27 February 2010 - 05:30 PM

AccountTest.java:4: cannot find symbol
symbol : class account
location: class AccountTest
account myAccount = new account();
^
AccountTest.java:4: cannot find symbol
symbol : class account
location: class AccountTest
account myAccount = new account();
^
2 errors

----jGRASP wedge2: exit code for process is 1.

That is what is says on my JGrasp. I'm sorry I'm not real sure what errors i have and I have been working at this for hours. Thanks
Was This Post Helpful? 0
  • +
  • -

#4 bella313  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 27-February 10

Re: Account Class

Posted 27 February 2010 - 05:37 PM

OK nevermind I figured it out. I didn't have my class saved in the same location as my main method. Thank You so much for your quick reply.
Was This Post Helpful? 0
  • +
  • -

#5 pdkharkar  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 63
  • View blog
  • Posts: 345
  • Joined: 19-January 09

Re: Account Class

Posted 27 February 2010 - 05:39 PM

in my compiler I am not getting these errors
but one thing you are doing wrong is that
you are declaring two public classes in the same source file
it should have only one public class
so I am declaring the class AccountTest as public as it contains the main method
now the program works fine
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1