Okay here is the just of my assignment: Write a test program that creates an Account object with an account ID of 1122, a balance 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 balance, the monthly interest, and the date when this account was created.
Here is my code:
public class Account {
private int accountNumber;
private double balance;
private double annualInterestRate;
private java.util.Date dateCreated;
//Default Constructor//
public Account() {
this(1122, 20000, 4.5);
}
public Account(int accountNumber, double balance, double annualInterestRate){
this.accountNumber = accountNumber;
this.balance = balance;
this.annualInterestRate = annualInterestRate;
dateCreated = new java.util.Date();
}
// Accesor for ID number //
public int getAccountNumber() {
return accountNumber;
}
// Mutator for ID number //
public void setAccountNumber(int accountNumber) {
this.accountNumber = accountNumber;
}
// Accesor for balance //
public double getBalance() {
return balance;
}
// Mutator for balance //
public void setBalance(double balance) {
this.balance = balance;
}
// Accesor for Annual Interest Rate //
public double getAnnualInterestRate() {
return annualInterestRate;
}
// Mutator for Annual Interest Rate //
public void setAnnualInterestRate( double annualInterestRate) {
this.annualInterestRate = annualInterestRate;
}
// Accesor for date created //
public java.util.Date getDateCreated() {
return dateCreated;
}
// Get the monthly interest rate //
public double getMonthlyInterestRate() {
double monthlyInterestRate = annualInterestRate/12;
return monthlyInterestRate;
}
// Withdraw from account //
public double withDraw (double ammountWithdrawn, double balance) {
double newBalance = balance - ammountWithdrawn;
System.out.println("Your withdrawl has processed. New balance: " + newBalance);
balance = (int) newBalance;
return newBalance;
}
// Deposit into account //
public double deposit(double amountDeposited, int balance) {
double newBalance = balance + amountDeposited;
System.out.println("Your deposit has processed. New Balance is: " + newBalance);
balance = (int) newBalance;
return newBalance;
}
// Main Method //
public static void main (String[] args) {
double withDraw = 2500;
double deposit = 3000;
System.out.println("Your balance is: " + balance);
System.out.println(monthlyInterestRate);
System.out.println(dateCreated);
}
}
Here is my problem:
1.It says it can't find the monthlyInterestRate symbol in the main.
2.If I delete the monthlyInterestRate print line in the main it compiles fine, but when it runs, I get:
java.lang.NoSuchMethodError: main
Exception in thread "main"
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
Any help would be appreciated.
Trey