You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
843 B

7 years ago
  1. public class Account{
  2. int id = 0;
  3. double startBalance = 0;
  4. double endBalance = 0;
  5. double monthlyInterestRate = 0.03;
  6. double interest;
  7. public Account (){
  8. }
  9. public Account (int id, double balance, double monthlyInterestRate){
  10. this.id = id;
  11. this.startBalance = balance;
  12. this.monthlyInterestRate = monthlyInterestRate;
  13. }
  14. public void computeInterest(){
  15. this.interest = this.startBalance * this.monthlyInterestRate;
  16. this.endBalance = this.startBalance+this.interest;
  17. }
  18. public void printAccountInfo(){
  19. // this.computeInterest();
  20. System.out.println("Account ID: " + this.id);
  21. System.out.println("Account Balance: " + this.startBalance);
  22. System.out.println("Interest gained: " + this.interest);
  23. System.out.println("New balance: " + this.endBalance);
  24. }
  25. }