//bank_account.h
#include<iostream>
using namespace std;
class Bank_Account{
private:
char
name[30],account_number[30];
double balance,interest_rate;
public:
Bank_Account();
Bank_Account(const
Bank_Account&);
//copy constructor
void operator == (const
Bank_Account&); //Operator overloading
void deposit(double);
void withdraw(double);
void calc_interest();
char* get_name();
char* get_account();
double get_balance();
double get_interest();
void
set_all(char[],char[],double,double);
};
//bank_account.cpp
#include<iostream>
#include<string.h>
#include "bank_account.h"
using namespace std;
Bank_Account::Bank_Account(){}
Bank_Account::Bank_Account(const Bank_Account
&obj) //copy
constructor
{
strcpy(name,obj.name);
strcpy(account_number,obj.account_number);
balance=obj.balance;
interest_rate=obj.interest_rate;
}
void Bank_Account::operator == (const Bank_Account &obj2)
{
if(strcmp(this->name,obj2.name)==0 &&
strcmp(this->account_number,obj2.account_number)==0
&&(this->balance==obj2.balance) &&
(this->interest_rate==obj2.interest_rate))
cout<<"The two accounts
"<<this->name<<" and "<<obj2.name<<" are
the same";
else
cout<<"The two accounts
"<<this->name<<" and "<<obj2.name<<" are
the different";
}
void Bank_Account::deposit(double amt)
{
balance += amt;
}
void Bank_Account::withdraw(double amt)
{
balance -= amt;
}
void Bank_Account::calc_interest()
{
balance += balance * interest_rate;
}
char* Bank_Account::get_name()
{
return name;
}
char* Bank_Account::get_account()
{
return account_number;
}
double Bank_Account::get_balance()
{
return balance;
}
double Bank_Account::get_interest()
{
return interest_rate;
}
void Bank_Account::set_all(char n[30],char account[30],double
bal,double interest)
{
strcpy(name,n);
strcpy(account_number,account);
balance=bal;
interest_rate=interest;
}
//bankacctdrvr.cpp
#include<iostream>
#include<stdio.h>
#include "bank_account.h"
using namespace std;
int main()
{
char *nam,*account; //Pointers to hold name and account number
Bank_Account acct1,acct2,acct3;
acct1.set_all("John Smith","206-345678",55000.00,0.08);
acct2.set_all("Paul Jones","206-436789",75000.00,0.05);
acct1.deposit(10000.00);
acct1.withdraw(5000.00);
acct1.calc_interest();
acct2.deposit(15000.00);
acct2.withdraw(7500.00);
acct2.calc_interest();
nam=acct1.get_name();
account=acct1.get_account();
printf("Name: %s\n",nam);
//Displaying the details
printf("Account: %s\n",account);
cout<<"Balance:
"<<acct1.get_balance()<<endl;
cout<<"Interest
rate:"<<acct1.get_interest()<<endl;
nam=acct2.get_name();
account=acct2.get_account();
printf("Name: %s\n",nam); //Displaying
the details
printf("Account: %s\n",account);
cout<<"Balance:
"<<acct2.get_balance()<<endl;
cout<<"Interest
rate:"<<acct2.get_interest()<<endl;
acct3 = acct2; // calling Copy constructor
nam=acct3.get_name();
account=acct3.get_account();
printf("Name: %s\n",nam); //Displaying
the details
printf("Account: %s\n",account);
cout<<"Balance:
"<<acct3.get_balance()<<endl;
cout<<"Interest
rate:"<<acct3.get_interest()<<endl;
acct2==acct3; //Operator overloading
}
Sample Output:

he class definition for a Hank Account class, contains the following private data nembers: the name,...
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 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...
Java Code:
2. Define a class ACCOUNT with the following members: Private members Acno of type int Name of type String Balance of type float Public members void Init) method to enter the values of data members void Show) method to display the values of data members void Deposit(int Amt) method to increase Balance by Amt void Withdraw(int Amt) method to reduce Balance by Amt (only if required balance exists in account) float RBalance() member function that returns the value...
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 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...
In C++ Write a program that contains a BankAccount class. The BankAccount class should store the following attributes: account name account balance Make sure you use the correct access modifiers for the variables. Write get/set methods for all attributes. Write a constructor that takes two parameters. Write a default constructor. Write a method called Deposit(double) that adds the passed in amount to the balance. Write a method called Withdraw(double) that subtracts the passed in amount from the balance. Do not...
in c++
Define and implement the class Employee with the following requirements: private data members string type name a. b. double type hourlyRate 2. public member functions a. default constructor that sets the data member name to blank"and hourlyRate to zero b. A constructor with parameters to initialize the private data members c. Set and get methods for all private data members d. A constant method weeklyPay() that receives a parameter representing the number of hours the employee worked per...
The Account class Create a class named Account, which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNumber(), getBalance(), setBalance(double newBalance). There is no setNumber() -- once an account is created, its account number cannot change. Now implement these methods: void deposit(double amount) and void withdraw(double amount). For both these methods,...
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...
Write a class called Player that has four data members: a string for the player's name, and an int for each of these stats: points, rebounds and assists. The class should have a default constructor that initializes the name to the empty string ("") and initializes each of the stats to -1. It should also have a constructor that takes four parameters and uses them to initialize the data members. It should have get methods for each data member. It...