Question

(The Account class) Design a class named Account that contains: A private int data field named...

(The Account class) 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 account (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 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 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 withdraw that withdraws a specified amount from the account.
A method named deposit that deposits a specified amount to the account.

Draw the UML diagram

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: As u mentioned to develop only the Account class code and UML Diagram , I am Providing it.

Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

UML Diagram For Account Class Account - id : int - balance : double - annuallnterestRate : double - date : Date + Account() +

_______________________

// Account.java

import java.util.Date;

public class Account {
   private int id;
   private double balance;
   private static double annualInterestRate;
   private Date date;

   public Account() {
       this.id = 0;
       this.balance = 0;
       this.annualInterestRate = 0;
       this.date = new Date();
   }

   public Account(int id, double initialBal) {
       this.id = id;
       this.balance = initialBal;
       this.annualInterestRate = 0;
       this.date = new Date();
   }

   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 static double getAnnualInterestRate() {
       return annualInterestRate;
   }

   public static void setAnnualInterestRate(double annualInterestRate) {
       Account.annualInterestRate = annualInterestRate;
   }

   public double getMonthlyInterest() {
       return balance * (annualInterestRate/1200);

   }

   public void withdraw(double amt) {
       if (amt <= balance) {
           balance -= amt;
       } else {
           System.out.println("** Account balance is low **");
       }
   }

   public void deposit(double amt) {

       balance += amt;

   }

   @Override
   public String toString() {
   System.out.println("\nAccount ID:" + id);
   System.out.println("Balance:" + balance);
   System.out.println("Monthly Interest:" + getMonthlyInterest());
   System.out.println("Date Created:" + date);
  
       return "";
   }
  
  

}


_______________Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
(The Account class) Design a class named Account that contains: A private int data field named...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 9.7 (The Account class) Design a class named Account that contains: • A private int data...

    9.7 (The Account class) Design a class named Account that contains: • A private int data field named id for the account (default o). • A private double data field named balance for the account (default o). • A private double data field named annualInterestRate that stores the current interest rate (default o). Assume that all accounts have the same interest rate. • A private Date data field named dateCreated that stores the date when the account was created. •...

  • Design a class named BankAccount that contains: 1. A private int data field named accountId for...

    Design a class named BankAccount that contains: 1. A private int data field named accountId for the account. 2. A private double data field named accountBalance for the account (default 0). 3. A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. 4. A private Date data field named dateCreated that stores the date when the account was created. 5. A private int data field named numberOfDeposits...

  • PYTHON PROGRAMMING LANGUAGE Design a class named Savings Account that contains: A private int data field...

    PYTHON PROGRAMMING LANGUAGE Design a class named Savings Account that contains: A private int data field named id for the savings account. A private float data field named balance for the savings account. A private float data field named annuallnterestRate that stores the current interest rate. A_init_ that creates an account with the specified id (default 0), initial balance (default 100), and annual interest rate (default 0). . The accessor and mutator methods for id, balance, and annuallnterestRate. A method...

  • Design a class that contains: we have to make 3 files header file , one .cpp...

    Design a class that contains: we have to make 3 files header file , one .cpp file for function and one more main cpp file 9.3 (The Account class) Design a class named Account that contains: An int data field named id for the account. A double data field named balance for the account. A double data field named annualInterestRate that stores the current interest rate. A no-arg constructor that creates a default account with id 0, balance 0, and...

  • Design a class named Account that contains: A private int datafield named id(default 0) A private...

    Design a class named Account that contains: A private int datafield named id(default 0) A private double datafield named balance(default 0) A no-arg constructor that creates default account A constructor that creates an account with specified id & balance The getter and setter methods for id and balance. Create an object of account class using default constructor and update the balance to 2000$ .

  • New to python if you can add screenshort also, i am using python 3 7.3 (The...

    New to python if you can add screenshort also, i am using python 3 7.3 (The Account class) Design a class named Account that contains A private int data field named id for the account. A private float data field named annualInterestRate that stores the current A constructor that creates an account with the specified id (default 0), initial The accessor and mutator methods for id, balance, and annualInterestRate A private float data field named balance for the account. interest...

  • Need help creating a Java program with mandatory requirements! VERY IMPORTANT: The George account class instance...

    Need help creating a Java program with mandatory requirements! VERY IMPORTANT: The George account class instance must be in the main class, and the requirement of printing a list of transactions for only the ids used when the program runs(Detailed in the Additional simulation requirements) is extremely important! Thank you so very much! Instructions: This homework models after a banking situation with ATM machine. You are required to create three classes, Account, Transaction, and the main class (with the main...

  • Design a class named BankAccount containing the following data field and methods. • One double data...

    Design a class named BankAccount containing the following data field and methods. • One double data field named balance with default values 0.0 to denote the balance of the account. • A no-arg constructor that creates a default bank account. • A constructor that creates a bank account with the specified balance.  throw an IllegalArgumentException when constructing an account with a negative balance • The accessor method for the data field. • A method named deposit(double amount) that deposits...

  • in java Account that contains: balance: double data field date: Date data field. Use Date class...

    in java Account that contains: balance: double data field date: Date data field. Use Date class from the java.util package accountNumber: long data field. You should generate this value randomly. The account number should be 9 digits long. You can you random method from java Math class. annuallnterestRate: double data field. customer: Customer data field. This is the other class that you will have to design. See description below. The accessor and mutator methods for balance, annuallnterestRate, date, and customer....

  • It is the year 2030, the MarsX Space Vehicles Company is in the process of designing...

    It is the year 2030, the MarsX Space Vehicles Company is in the process of designing its X-2 single use Space Transportation Systems (STS). You have been tasked with creating a class to model a single STS. Design a class named STS (Space Transportation System) that contains: 1. A private int data field named STSId for the STS registration ID. 2. A private Date data field named dateCreated that stores the date when the STS was created. 3. A private...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT