Question

In: Computer Science

In C++, define the class bankAccount to implement the basic properties of a bank account. An...

In C++, define the class bankAccount to implement the basic properties of a
bank account. An object of this class should store the following data:
Account holder’s name (string), account number (int), account type
(string, checking/saving), balance (double), and interest rate (double).
(Store interest rate as a decimal number.) Add appropriate member functions
to manipulate an object. Use a static member in the class to
automatically assign account numbers. Also declare an array of 10 components
of type bankAccount to process up to 10 customers and write a
program to illustrate how to use your class.

Solutions

Expert Solution

#include<bits/stdc++.h>
using namespace std;

class bankAccount{
  
   string name;
   int accountNumber;
   string accountType;
   double balance,interest;
  
   public:
   static int account;
   bankAccount(){}
   bankAccount(string n,string t,double b,double i)
   {
       accountNumber=account;
       account++;
       name=n;
       accountType=t;
       balance=b;
       interest=i;
   }
  
   void display()
   {
       cout<<"Account Number: "<<accountNumber<<endl;
       cout<<"Name: "<<name<<endl;
       cout<<"Account Type: "<<accountType<<endl;
       cout<<"Balance: "<<balance<<endl;
       cout<<"Interest: "<<interest<<endl;
       cout<<endl;
   }
  
   void setBalance(double b)
   {
       balance=b;
   }
  
   void setInterest(double i)
   {
       interest=i;
   }
};
int bankAccount::account=1000;

int main()
{
   bankAccount * customer=new bankAccount[10];
  
   //declaring 10 customers
   customer[0]=bankAccount("ABC","SAVINGS",15000,5.2);
   customer[1]=bankAccount("DEF","SAVINGS",5000,4.2);
   customer[2]=bankAccount("GHI","CHECKING",25000,6.2);
   customer[3]=bankAccount("JKL","SAVINGS",50000,8.1);
   customer[4]=bankAccount("MNO","CHECKING",125000,16);
   customer[5]=bankAccount("PQR","SAVINGS",175000,1.3);
   customer[6]=bankAccount("STU","SAVINGS",1000,23.2);
   customer[7]=bankAccount("VWX","CHECKING",200,14.2);
   customer[8]=bankAccount("YZS","CHECKING",25300,3.6);
   customer[9]=bankAccount("CSD","SAVINGS",745000,7.2);
   cout<<"Details of customers are:"<<endl;
   for(int i=0;i<10;i++)
   {
       cout<<"======================================="<<endl;
       customer[i].display();
       cout<<"======================================="<<endl;
   }
   customer[0].setBalance(102354);
   customer[0].setInterest(9.9);
   customer[0].display();
}


Related Solutions

c++ programming 1.1 Class definition Define a class bankAccount to implement the basic properties of a...
c++ programming 1.1 Class definition Define a class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data:  Account holder’s name (string)  Account number (int)  Account type (string, check/savings/business)  Balance (double)  Interest rate (double) – store interest rate as a decimal number.  Add appropriate member functions to manipulate an object. Use a static member in the class to automatically assign account numbers. 1.2 Implement...
a. Define the class bankAccount to store a bank customer’s account number and balance. Suppose that...
a. Define the class bankAccount to store a bank customer’s account number and balance. Suppose that account number is of type int, and balance is of type double. Your class should, at least, provide the following operations: set the account number, retrieve the account number, retrieve the balance, deposit and withdraw money, and print account information. Add appropriate constructors. b. Every bank offers a checking account. Derive the class checkingAccount from the class bankAccount (designed in part (a)). This class...
using C++ Please create the class named BankAccount with the following properties below: // The BankAccount...
using C++ Please create the class named BankAccount with the following properties below: // The BankAccount class sets up a clients account (using name & id), and - keeps track of a user's available balance. - how many transactions (deposits and/or withdrawals) are made. public class BankAccount { private int id; private String name private double balance; private int numTransactions; // ** Please define method definitions for Accessors and Mutators functions below for the class private member variables string getName();...
13. The class bankAccount stores a bank customer’s account number and balance. Suppose that account number...
13. The class bankAccount stores a bank customer’s account number and balance. Suppose that account number is of type int, and balance is of type double. This class provides the following operations: set the account number, retrieve the account number, retrieve the balance, deposit and withdraw money, and print account information. b. The class  checkingAccount from the class bankAccount (designed in part a). This class inherits members to store the account number and the balance from the base class. A customer...
Write a program to create a bank account and to process transactions. Call this class bankAccount...
Write a program to create a bank account and to process transactions. Call this class bankAccount A bank account can only be given an initial balance when it is instantiated. By default, a new bank account should have a balance of 0. A bank account should have a public get method, but no public set method. A bank account should have a process method with a double parameter to perform deposits and withdrawals. A negative parameter represents a withdrawal. It...
1.   Design a class, Account, that models the basic workings of a bank account. The class...
1.   Design a class, Account, that models the basic workings of a bank account. The class should perform the following tasks: a.   Save the account balance. b.   Save the number of transactions performed on the account. c.   Allow deposits to be made to the account. d.   Allow withdrawals to be taken from the account. e.   Calculate interest for the period. f.   Report the current account balance at any time. g.   Report the current number of transactions at any time The...
In c++, define a class with the name BankAccount and the following members: Data Members: accountBalance:...
In c++, define a class with the name BankAccount and the following members: Data Members: accountBalance: balance held in the account interestRate: annual interest rate. accountID: unique 3 digit account number assigned to each BankAccount object. Use a static data member to generate this unique account number for each BankAccount count: A static data member to track the count of the number of BankAccount objects created. Member Functions void withdraw(double amount): function which withdraws an amount from accountBalance void deposit(double...
1.   Design a class called BankAccount. The member fields of the class are: Account Name, Account...
1.   Design a class called BankAccount. The member fields of the class are: Account Name, Account Number and Account Balance. There are also other variables called MIN_BALANCE=9.99, REWARDS_AMOUNT=1000.00, REWARDS_RATE=0.04. They look like constants, but for now, they are variables of type double Here is the UML for the class:                                                         BankAccount -string accountName // First and Last name of Account holder -int accountNumber // integer -double accountBalance // current balance amount + BankAccount()                     //default constructor that sets name to “”,...
c++ The above Account class was created to model a bank account. An account has the...
c++ The above Account class was created to model a bank account. An account has the properties (keep the properties private) account number, balance, and annual interest rate, date created, and functions to deposit and withdraw. Create two derived classes for checking and saving accounts. A checking account has an overdraft limit, but a savings account cannot be overdrawn. Define a constant virtual toString() function in the Account class and override it in the derived classes to return the account...
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main()...
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main() function to coordinate the execution of the program. We will need methods: Method for Depositing values into the account. What type of method will it be? Method for Withdrawing values from the account. What type of method will it be? Method to output the balance of the account. What type of method will it be? Method that will output all deposits made to the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT