Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is java btw. This is what I have so far: But it is not working import java.

ID: 653688 • Letter: T

Question

This is java btw.

This is what I have so far:

But it is not working

import java.util.*;
public class Account {
   private int id = 0;
   private double balance = 0;
   private double annualInterestRate = 0;
   private long dateCreated = 0;
   private long SimpleDateFormat;
   dateCreated dc = new Date(dateCreated.getTime());
  
   public Account(int id, double balance) {
   super();
   this.id = id;
   this.balance = balance;
   this.dateCreated = System.currentTimeMillis();
   }
   public int getId() {
return id;
   }
   public double getBalance() {
return balance;
   }
   public double getAnnualInterestRate() {
return annualInterestRate;
}
   public void setId(int id) {
this.id = id;
   }
   public void setBalance(double balance) {
this.balance = balance;
   }
   public void setAnnualInterestRate(double annualInterestRate) {
this.annualInterestRate = annualInterestRate;
}
   public double getDateCreated() {
   return dateCreated;
   }
   double getMonthlyInterestRate() {
return (annualInterestRate/12);
   }
   public double getMonthlyInterest() {
   return getMonthlyInterestRate() * balance;
   }
public void withdraw(double amount) {
   setBalance(getBalance() - amount);
   }
   public void deposit(double amount) {
   setBalance(getBalance() + amount);
   }
   public String toString() {
   return "Account ID: " + id + " " + "Account Balance: " + balance + " " + "InterestRate: " + annualInterestRate + " " + "DateOpened: " + dateCreated;
   }
}

public class TestAccount {

   public static void main(String[] args) {
  
Account myAccount = new Account(34598755, 2754.00, 2.75);
myAccount.withdraw(2500.00);
myAccount.deposit(3000.00);
System.out.println("Balance: " + myAccount.balance);
System.out.println("Monthly Interest: " + myAccount.getMonthlyInterestRate());
System.out.println("Account created on: " + myAccount.dateCreated);
  
   }

}

Explanation / Answer

//James Morris, Assignment 2, 10.7 - ATM Simulator package atmSimulator; import java.util.Date; public class Account { //MEMBER VARIABLES private int id = 0; private double balance = 0.0; private double annualInterestRate; private Date dateCreated = new Date(); //CONSTRUCTORS Account(){} Account(int id, double balance){ setId(id); setBalance(balance); } //SETS public void setId(int id) {this.id = id;} public void setBalance(double balance) {this.balance = balance;} public void setAnnualInterestRate(double annualInterestRate){this.annualInterestRate = annualInterestRate;} //GETS public int getId() {return id;} public double getBalance() {return balance;} public double getAnnualInterestRate() {return annualInterestRate;} public Date getDate() {return (Date)dateCreated.clone();} //METHODS public double getMonthlyInterestRate(){return getAnnualInterestRate()/12;} public double getMonthlyInterest(){return getBalance()*(getAnnualInterestRate()/1200);} public void withdraw(double amount){setBalance(getBalance() - amount);} public void deposit(double amount){setBalance(getBalance() + amount);} }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote