Question: Hello, I'm very new to programming and I'm running into a problem with the system.out.println function in the TestAccount Class pasted below. Account Class: import

Hello, I'm very new to programming and I'm running into a problem with the system.out.println function in the TestAccount Class pasted below.

Account Class:

import java.util.Date; public class Account {

private int accountId; private double accountBalance, annualInterestRate; private Date dateCreated;

public Account(int id, double balance) { id = accountId; balance = accountBalance; dateCreated = new Date(); }

public Account() { dateCreated = new Date(); }

public int getId() { return accountId; }

public double getAnnualInterestRate() { return annualInterestRate; } public String getDateCreated() { return dateCreated.toString(); } public double getMonthlyInterest() { return annualInterestRate / 12; } public double getBalance() { return accountBalance; } public void setId(int id) { accountId = id; } public void setBalance(double balance) { accountBalance = balance; } public void setaccountAnnualInterestRate(double d) { annualInterestRate = d; }

public void deposit(double a) { accountBalance += a; } public void withdraw(double i) { if(accountBalance >= i) { accountBalance -= i; } }

}

TestAccount Class:

public class TestAccount {

public static void main(String[] args) { Account account = new Account(1122, 20000); account.setaccountAnnualInterestRate(4.5); account.setId(1122); account.setBalance(20000); System.out.println("Balance before withdrawal is " + account.getBalance()); // this line won't print every other line works. Please help me solve this issue. System.out.println("Your account ID is: " + account.getId()); System.out.println("The annual interest rate is " + account.getAnnualInterestRate()); account.withdraw(2500); System.out.println("Balance after withdrawal is " + account.getBalance()); account.deposit(3000); System.out.println("Your current balance is " + account.getBalance()); System.out.println("Monthly interest is " + account.getMonthlyInterest()); System.out.println("This account was created at " + account.getDateCreated());

}

}

What am i doing wrong? Please help correct the code. Thank you.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!