so i have an assignment for a java programming II class that requires me to create a class called Account that is to do the following:
Design a class named Account that contains:
Data Members:
A private data filed of type int named id for the account;
A private data field of type double named balance for the account;
A private data field of type double named annualInterestRate that stores the current interest rate (assume all accounts have the same interest rate);
A private data field of type Date named dateCreated that stores the date when the account was created;
Methods A no-arg constructor that creates a default account and sets the following data members to 0 (zero): id, balance, and annualInterestRate;
A constructor that creates an account with the specified id and initial balance;
The accessor and mutator methods for id, balance and annualInterestRate;
The accessor method for dateCreated
A method named getMonthlyInterestRate( ) that returns the monthly interest rate;
A method named getMonthlyInterest( ) that returns the monthly interest;
A method named withdraw that withdraws a specified amount from the account;
A method named deposit that deposits a specified amount into the account.
Write a test program that creates an Account object with an account ID of 1122, a balance of $20,000, and an annual interest rate of 4.5%. Use the withdraw method to withdraw $2,500, use the deposit method to deposit $3,000, and print the balance, the monthly interest, and the date when this account was created.
the tester app has been given to us by the professor, which i will link down below. all that is required is to create the Account class, which i have. everything compiles correctly, however when i run the tester app the output i get is very odd :
----jGRASP exec: java AccountTest
Current account values:
Account@208e2fb5
Current account values:
Account@208e2fb5
Current account values:
Account@208e2fb5
im at a loss right now, i have no idea what to do or where to go from here.
Tester App:
public class AccountTest
{
public static void main(String [] args)
{
Account a = new Account(1122, 20000.00);
a.setAnnualInterestRate(4.5);
System.out.println("\nCurrent account values: \n" + a);
a.withdraw(2500.00);
System.out.println("\nCurrent account values: \n" + a);
a.deposit(3000.00);
System.out.println("\nCurrent account values: \n" + a);
}
}
Account Class i created:
import java.util.Date;
public class Account
{
private int id;
private double balance;
private double annualInterestRate;
private Date date = new Date();
Account()
{
id = 0;
balance = 0.0;
annualInterestRate = 0.0;
}
Account(int newId, double bal)
{
id = newId;
balance = bal;
}
public void setId(int newId)
{
id = newId;
}
public void setBalance( double bal)
{
balance = bal;
}
public void setAnnualInterestRate(double annualRate)
{
annualInterestRate = annualRate;
}
public int getId()
{
return id;
}
public double getBalance()
{
return balance;
}
public double getAnnualInterestRate()
{
return annualInterestRate;
}
/*public void setDate(Date n)
{
dateCreated = n;
}*/
public java.util.Date getDate()
{
return date;
}
double getMonthlyInterestRate()
{
return annualInterestRate/12;
}
double withdraw(double amount)
{
return balance -= amount;
}
double deposit(double amount)
{
return balance += amount;
}
}
apologies in advanced for my formatting.