*A private int data field named id for the account (default 0)
*A private double data field named balance for the account (default 0)
*A private double data field named anualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate.
* A private Date data field named dateCreated that stores the date when the account was created.
*A no-arg constructor that creates a default account.
*A constructor that creates an account with a specified id and initial balance.
*The accessor and mutator method for id, balance, and annualInterestRate
*The accessor method for dateCreated
* A method named getMonthlyInterestRate() that returns tyhe monthly interest rate.
*A method named withdraw that withdraws a specified amount from the account
*A method named deposit that deposits a specified amount from the account.
Draw the UML diagram for the class. Implement the class. 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.
This is what a classmate and I were able to produce this morning, but I am still stuck on one error that is driving me crazy:
public Account(int id, double balance, doubleannualInterestRate)<--- "Cannot find symbol, Identifier expected"
package account;
/**
*
* @author TM2011
*/
import java.util.*;
public class Account{
private int id=0;
private double balance = 0;
private double annualInterestRate = 0;
private Date dateCreated;
public Account()
{
this.id =0;
this.balance =0;
this.annualInterestRate =0;
this. dateCreated = new Date();
}
public Account(int id, double balance, doubleannualInterestRate)
{
this.id =id;
this.balance =balance;
this.annualInterestRate =annualInterestRate;
this. dateCreated = new Date();
}
public void setID(int id) {
this.id=id;
}
public int getID() {
return this.id;
}
public void setBalance(double balance) {
this.balance = balance;
}
public double getbalance(){
return this.balance;
}
public void setAnnualInterestrate(double annualInterestRate) {
this.annualInterestRate =annualInterestRate;
}
public double getAnnualInterestrate() {
return this.annualInterestRate;
}
public Date getDateCreated() {
return this.dateCreated;
}
public double getMonthlyInterestRate() {
return (this.annualInterestRate)/12;
}
public void withdraw(double amount) {
if( this.balance <amount)
{
System.out.println("Insufficent balance in the account");
}
else
{
this.balance -=amount;
System.out.println("Afterwithdrawing "+ amount +" balance in "
+ "accountis: " +this.balance);
}
}
public void deposit(double amount)
{
this.balance += amount;
System.out.println(" Afterdepositing " + amount + " balance inaccount"
+ " is:" + this.balance);
}
public static void main(String args[]){
Account ac= new Account( 1122, 20000, 4.5);
ac.withdraw(2500);
ac.deposit(3000);
System.out.println("balance in account " + ac.getID() +"is: " +ac.getbalance());
System.out.println("Monthly Interest is: " + (ac.getMonthlyInterestRate()
* ac.getbalance()) /100);
System.out.println("Account is created on: " +ac.getDateCreated());
}
}
Thanks for taking a look!

New Topic/Question
Reply




MultiQuote








|