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

Design a class named Account that contains: * A private int data field named id

ID: 3530060 • Letter: D

Question

Design a class named Account that contains: * A private int data field named id for the account (default 0). * A private double data field named balance for the count (default 0). * A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. * A private Date (class) data field named dateCreated that stores the date when the account was created. * A no-args constructor that creates a default account. * 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 deposit a specified amount to the account.

Explanation / Answer

This is the exact answer to your que ..check it out ..it 100% working

Account Class

import java.util.Date;
public class Account {

/**
* @param args
*/
private int id=0;
private double balance=0;
private double annualIntrestRate=0;
private Date dateCreated;

public Account() {
super();
}




public Account(int id, double balance) {
super();
this.id = id;
this.balance = balance;
}





public int getId() {
return id;
}




public void setId(int id) {
this.id = id;
}




public double getBalance() {
return balance;
}




public void setBalance(double balance) {
this.balance = balance;
}




public double getAnnualIntrestRate() {
return annualIntrestRate;
}



public void setAnnualIntrestRate(double annualIntrestRate) {
this.annualIntrestRate = annualIntrestRate;
}




public Date getDateCreated() {
return dateCreated;
}




public void setDateCreated(Date dateCreated) {
this.dateCreated = dateCreated;
}

public double getMonthlyInterestRate()
{
return (this.getAnnualIntrestRate()/12);
}
public double getMonthlyInterest()
{
return (getBalance() *getMonthlyInterestRate()/100);
}
public double withDraw(double balance)
{
this.setBalance(this.getBalance()-balance);
return this.getBalance();
}
public double diposite(double balance)
{
this.setBalance(this.getBalance()+balance);
return this.getBalance();
}
public double totalBalance()
{
balance =balance + getMonthlyInterest();
return balance;
}
}

AccountTest Class(Main driver class)


import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;
public class AccountTest {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

Scanner sc=new Scanner(System.in);
Account ac=new Account(1,5000.00);
System.out.println("Enter the annual intrest rate");
double intrestRate=sc.nextDouble();
ac.setAnnualIntrestRate(intrestRate);
Date d=new Date();
Calendar currentDate = Calendar.getInstance();
ac.setDateCreated(currentDate.getTime());
System.out.println("Date id "+ac.getDateCreated());
System.out.println("Monthly intrest rate is :"+ac.getMonthlyInterestRate());
System.out.println("Monthly intrest is :"+ac.getMonthlyInterest());
System.out.println("Enter Amount for diposite ");
double dipositeAmount=sc.nextDouble();
System.out.println("The amount after diposite is :"+ac.diposite(dipositeAmount));
System.out.println("Enter Amount to withdraw :");
double withdramount= sc.nextDouble();
System.out.println("The amount remain after with draw "+ac.withDraw(withdramount));
System.out.println("The total amount is "+ac.totalBalance());

}

}


Sample output :

Enter the annual intrest rate
2.5
Date id Thu Mar 07 04:55:38 IST 2013
Monthly intrest rate is :0.208
Monthly intrest is :10.42
Enter Amount for diposite
300
The amount after diposite is :5300.0
Enter Amount to withdraw :
3000
The amount remain after with draw 2300.0
The total amount is 2304.79


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