Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions