I have to write a code with netbeans for my homework and this is what I need to do
"please create Main.java to test the Account class. In the main() method, create an Account object named myAcct with an account ID of 1122, a balace of $20000, and an annual interest rate of 4.5%. use the withdraw method to withdraw $2500, use the deposit method to deposit $3000, and print the account information."
this is how it suppose to look like
Original informatin aobut myacct
########################
#id:1122
#balance: 20000
#annualinterest rate: 4.5
########################
information about myacct after withdraw and deposit
########################
#id:1122
#balance: 20500
#annualinterest rate: 4.5
########################
the monthly interest of myacct: 76.88
So far this is what I got:
main method
Account myAcct = new Account ("1122", 20000, 4.5);
System.out.println(myAcct);
The Account java class:
public class Account {
//define class variables
private String id;
private double balance;
private double annualInterestRate;
/** Creates a new instance of Account */
public Account() {
}
public Account (String id, double balance, double annualInterestRate)
{
this.id = id;
this.balance = balance;
this.annualInterestRate = annualInterestRate;
}
//define get methods
public String getId()
{
return id;
}
public double getBalance()
{
return balance;
}
public double getAnnualInterestRate()
{
return annualInterestRate;
}
//define set methods
public void setId (String id)
{
this.id = id;
}
public void setBalance (double balance)
{
this.balance = balance;
}
public void setAnnualInterestRate(double annualInterestRate)
{
this.annualInterestRate = annualInterestRate;
}
public double getMonthlyInterestRate()
{
return annualInterestRate/1200;
}
public double getMonthlyInterest()
{
return balance*getMonthlyInterestRate();
}
public String toString()
{
String report = "###############################################" +"\n"
+ "ID:" + id + "\n"
+ "Balance:" + balance + "\n"
+ "Annual Interest Rate:" + annualInterestRate + "\n"
+ "##################################################" + "\n"
+ "The monthly interest of myacct:" + getMonthlyInterest();
return report;
}
I need help with the withdraw and deposit. anything suggestion is great thank you