Question

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 annualInterestRate 0.

  • The accessor and mutator functions for id, balance, and annualInterestRate.

  • A function named getMonthlyInterestRate() that returns the monthly interest rate.

  • A function named withdraw(amount) that withdraws a specified amount from the account.

  • A function named deposit(amount) that deposits a specified amount to 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 20000, and an annual interest rate of 4.5%. Use the withdraw function to withdraw $2500, use the deposit function to deposit $3000, and print the balance, the monthly interest.

please have the code to copy. Thnaks

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

Thanks for the question.
Here is the completed code for this problem. Comments are included so that you understand whats going on. Let me know if you have any doubts or if you need anything to change.
Thank You !!
========================================================================================

#ifndef ACCOUNT_H
#define ACCOUNT_H

class Account
{
   public:
       Account();
       Account(int,double,double);
       int getID()const;
       double getBalance() const;
       double getAnnualInterest() const;
       double getMonthlyInterestRate() const;
       void withdraw(double);
       void deposit(double);
      
   private:
       int id;
       double balance;
       double annualInterestRate;
      
};

#endif

========================================================================================

#include "Account.h"

   Account::Account(){
       this->id=0;
       this->balance=0;
       this->annualInterestRate=0.0;
   }
   Account::Account(int id,double bal,double interest){
       this->id=id;
       this->balance=bal;
       this->annualInterestRate=interest;
   }
   int    Account::getID()const{
   return this->id;
   }
   double    Account::getBalance() const{
   return this->balance;
   }
   double    Account::getAnnualInterest() const{
   return this->annualInterestRate;
   }
   double    Account::getMonthlyInterestRate() const{
   return this->annualInterestRate/12.0;
   }
   void    Account::withdraw(double amount){
       this->balance-=amount;
   }
   void    Account::deposit(double amount){
       this->balance+=amount;
   }

========================================================================================

#include <iostream>
#include "Account.h"
using namespace std;

int main() {
   Account account = Account(1122,20000,4.5);
   cout<<"Account ID: "<<account.getID()<<", Balance: $"<<account.getBalance()<<endl;
   account.withdraw(2500);
   cout<<"Account ID: "<<account.getID()<<", Balance: $"<<account.getBalance()<<endl;
   account.deposit(3000);
   cout<<"Account ID: "<<account.getID()<<", Balance: $"<<account.getBalance()<<endl;
  
   return 0;
}

========================================================================================


UML Diagram

Add a comment
Know the answer?
Add Answer to:
Design a class that contains: we have to make 3 files header file , one .cpp...
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. •...

  • (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...

  • 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...

  • 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 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...

  • Unable to find out why am I getting: Account.java:85: error: reached end of file while parsing...

    Unable to find out why am I getting: Account.java:85: error: reached end of file while parsing import java.util.*; class Account{ private int id; private double balance; private double annualInterestRate; private Date dateCreated; public Account() { id = 0; balance = 0; annualInterestRate = 0; dateCreated = new Date(); } public Account(int id1, double balance1) { id =id1; balance = balance1; dateCreated = new Date(); } public void setId(int id1) { id=id1; } public void setBalance(double balance1) { balance = balance1;...

  • The code is attached below has the Account class that was designed to model a bank account.

    IN JAVAThe code is attached below has the Account class that was designed to model a bank account. An account has the properties account number, balance, annual interest rate, and date created, and methods to deposit and withdraw funds. I need creat program using the 2 java programs.Create two subclasses for checking and savings accounts. A checking account has an overdraft limit, but a savings account cannot be overdrawn.I need to write a test program that creates objects of Account,...

  • Consider the following Account class and main function: class Account: acct_num=1000 #Constructor for Account class (default...

    Consider the following Account class and main function: class Account: acct_num=1000 #Constructor for Account class (default values for balance #and annual interest rate are 100 and e, respectively). #INITIALIZER METHOD HEADER GOES HERE #MISSING CODE def getId(self): return self._id def getBalance(self): #MISSING CODE def getAnnualInterestRate(self): return self.___annualInterestRate def setBalance(self, balance): self. balance - balance def setAnnualInterestRate(self,rate): #MISSING CODE def getMonthlyInterestRate(self): return self. annualInterestRate/12 def getMonthlyInterest (self): #MISSING CODE def withdraw(self, amount): #MISSING CODE det getAnnualInterestRate(self): return self. annualInterestRate def setBalance(self,...

  • 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...

  • 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$ .

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