Question

C++ Design and implement a hierarchy inheritance system of banking, which includes Savings and Checking accounts...

C++

Design and implement a hierarchy inheritance system of banking, which includes Savings and Checking accounts of a customer. Inheritance and virtual functions must be used and applied, otherwise, there is no credit. The following features must be incorporated:

1. The account must have an ID and customer’s full name and his/her social security number.

2. General types of banking transactions for both accounts, Checking and Savings: withdraw, deposit, calculate interest (based on the current balance, and if it was not modified, there will be no new interest), figure out the balance, and transfer funds (between the two accounts, from Checking to Savings and vice versa).

3. Savings restrictions: Become inactive if the balance falls less than $25, and under such situation, no more activities may be allowed. Also the resulted balance that goes below $25 is not accepted. A $1 charge for each transfer fund (to Checking account), with the first transfer is free. The monthly interest rate is 3.75%.

4. Checking restrictions: A monthly service charge is $5 (automatically be charged when Checking account was opened). A 10 cents charge for each written check, with the first check is free. A $15 charge for each bounced check (not enough funds). The monthly interest rate is 2.5%.

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

#include<iostream>

using namespace std;

//A base class named Account is created

class Account

{

protected:

double acc_blnc;

public:

Account(double);

bool credit(double);

bool debit(double);

double getBalance();

void assgn(double);

};

//Parameterized constructor, used to initialize account balance

Account::Account(double blnc)

{

if(blnc<=0.0)

{

cout<<"\nInvalid amount entered!!\n";

acc_blnc=0.0;

}

else

acc_blnc=blnc;

}

//This function is used to assign current balance to the account

void Account::assgn(double bl)

{

acc_blnc=bl;

}

//This function is used to add an amount to the current balance

bool Account::credit(double amount)

{

if(amount<=0.0)

{

cout<<"\nTransaction unsucessful!!Please enter a valid amount.\n";

return false;

}

acc_blnc+=amount;

cout<<"\nTransaction completed succcessfully...\n";

return true;

}

//This function is used to withdraw money from the Account

bool Account::debit(double amount)

{

if(amount<=0.0)

{

cout<<"\nTransaction unsucessful!!Please enter a valid amount.\n";

return false;

}

if(amount>acc_blnc)

{

cout<<"\nTransaction unsucessful!!Debit amount exceeded account balance...\n\n";

return false;

}

acc_blnc-=amount;

cout<<"\nTransaction completed succcessfully...\n";

return true;

}

//This function is used to return the current balance

double Account::getBalance()

{

return acc_blnc;

}

//Derived class named SavingsAccount is created which is derived from base class Account

class SavingsAccount:public Account

{

protected:

double interest_rate;

public:

SavingsAccount(double,double);

double CalculateInterest();

};

//Parameterized constructor, used to initialize interest rate and receive initial balance

SavingsAccount::SavingsAccount(double balance,double percentage):Account(balance)

{

acc_blnc=balance;

interest_rate=percentage;

}

//This function is used to return the amount of interest earned by an account

double SavingsAccount::CalculateInterest()

{

return acc_blnc*(interest_rate/100);

}

//Derived class named CheckingAccount is created which is derived from base class Account

class CheckingAccount:public Account

{

protected:

double fee;

public:

CheckingAccount(double,double);

double credit(double);

double debit(double);

};

//Parameterized constructor, used to initialize fee charged per transaction and receive initial balance

CheckingAccount::CheckingAccount(double balance,double fee_amount):Account(balance)

{

acc_blnc=balance;

fee=fee_amount;

}

//This function should charge a fee only if money is actually added

double CheckingAccount::credit(double amount)

{

if((amount-fee)>=0.0)

{ amount-=fee;

cout<<"\nFee charged succcessfully...\n";

}

else

amount=-99;

return amount;

}

//This function should charge a fee only if money is actually withdrawn

double CheckingAccount::debit(double amount)

{

if((amount-fee)>=0.0)

{

amount-=fee;

cout<<"\nFee charged succcessfully...\n";

}

else

amount=-99;

return amount;

}

int main()

{

double bal;

cout<<"Enter initial account balance:";

cin>>bal;

Account ac(bal);

double i_rate=4.0,fee=30.00;

cout<<"\n\n";

int ch;

while(true)

{

cout<<"\nBANK\n---------------------\n""\n1.Administrator.\n2.Normal user.\n3.Exit.\n\n";

cout<<"Enter your choice:";

cin>>ch;

switch(ch)

{

case 1:

cout<<"\n1.Change interest rate.\n2.Change fee charged per transaction.\n3.Add interest to account\n\n";

cout<<"Enter your choice:";

cin>>ch;

switch(ch)

{

case 1:

cout<<"Enter new interest rate:";

cin>>i_rate;

break;

case 2:

while(true)

{

cout<<"Enter a new valid amount of fee charged per transaction:";

cin>>fee;

if(fee>=0.0)

break;

cout<<"\nInvalid amount of fee entered!!\n";

}

break;

case 3:

{

SavingsAccount sav(ac.getBalance(),i_rate);

double interest=sav.CalculateInterest();

if((ac.credit(interest)==true))

cout<<"\nInterest added successfully.\n";

}

break;

default:

cout<<"Invalid choice entered!!\n";

}

break;

case 2:

cout<<"\n1.Deposit balance.\n2.Withdraw balance.\n\n";

cout<<"Enter your choice:";

cin>>ch;

switch(ch)

{

case 1:

{

CheckingAccount acc(ac.getBalance(),fee);

cout<<"Enter amount to deposit:";

cin>>bal;

if((ac.credit(bal)==true))

{

bal=acc.credit(ac.getBalance());

if(bal==-99)

{

cout<<"\nFee charge is not successful,operation terminated!!\n";

return 0;

}

ac.assgn(bal);

}

}

break;

case 2:

{

CheckingAccount acc(ac.getBalance(),fee);

cout<<"Enter amount to withdraw:";

cin>>bal;

if((ac.debit(bal)==true))

{

bal=acc.debit(ac.getBalance());

if(bal==-99)

{

cout<<"\nFee charge is not successful,operation terminated!!\n";

return 0;

}

ac.assgn(bal);

}

}

break;

default:

cout<<"Invalid choice entered!!\n";

}

break;

case 3:

return 0;

default:

cout<<"Invalid choice entered!!\n";

}

}

}GAC SlideslprogramslHomeworkLib_bank.exe The anount to be de posited is:288 our current balance is :2200 our current interest is 264 The amount to withdraw is:500 our current balance is 1700 The amount to withdraw is 100 Unable to withdraw, your account has low balance our current balance is :20 The amount to be deposited is 2000 our current balance is:2020 our current balance is :1720

Add a comment
Know the answer?
Add Answer to:
C++ Design and implement a hierarchy inheritance system of banking, which includes Savings and Checking accounts...
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
  • Should be in C# Create an inheritance hierarchy that a bank might use to represent customers’...

    Should be in C# Create an inheritance hierarchy that a bank might use to represent customers’ bank accounts. All customers at this back can deposit (i.e. credit) money into their accounts and withdraw (i.e. debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction. Create base class Account and derived classes SavingsAccount and CheckingAccount that inherit...

  • c++ help please. Savings accounts: Suppose that the bank offers two types of savings accounts: one...

    c++ help please. Savings accounts: Suppose that the bank offers two types of savings accounts: one that has no minimum balance and a lower interest rate and another that requires a minimum balance but has a higher interest rate (the benefit here being larger growth in this type of account). Checking accounts: Suppose that the bank offers three types of checking accounts: one with a monthly service charge, limited check writing, no minimum balance, and no interest; another with no...

  • C++ Banks offer various types of accounts, such as savings, checking, certificate of deposits, and money...

    C++ Banks offer various types of accounts, such as savings, checking, certificate of deposits, and money market, to attract customers as well as meet their specific needs. Two of the most commonly used accounts are savings and checking. Each of these accounts has various options. For example, you may have a savings account that requires no minimum balance but has a lower interest rate. Similarly, you may have a checking account that limits the number of checks you may write....

  • 2.(11') Checking/savings. Suppose a person has three accounts: checking, savings and retirement. Each month, the checking...

    2.(11') Checking/savings. Suppose a person has three accounts: checking, savings and retirement. Each month, the checking account is credited with a pay check. Each month the person pays rent, utilities, and other expenses from the checking account and makes a deposit into savings and into retirement (assume all these amounts are the same from month to month). The checking account has a monthly fee and earns no interest. The savings and retirement accounts earn interest. Furthermore, the person has a...

  • must be written in c# using windows application Scenario: Samediff bank has a 25-year old banking...

    must be written in c# using windows application Scenario: Samediff bank has a 25-year old banking account system. It was created using procedural programming. Samediff bank needs to improve the security and maintainability of the system using an object-oriented programming (OOP) approach. Their bank manager has decided to hire you to develop, implement, and test a new OOP application using efficient data structures and programming techniques.Samediff banks manager is excited to consider updating their account system. An expert has advised...

  • the programing language is C++ TIC PEO. Design a generic class to hold the following information...

    the programing language is C++ TIC PEO. Design a generic class to hold the following information about a bank account! Balance Number of deposits this month Number of withdrawals Annual interest rate Monthly service charges The class should have the following member functions: Constructor: Accepts arguments for the balance and annual interest rate. deposit: A virtual function that accepts an argument for the amount of the deposit. The function should add the argument to the account balance. It should also...

  • 4. Interest-paying checking accounts - Their features and uses What Are Interest-Paying Checking Accounts and How...

    4. Interest-paying checking accounts - Their features and uses What Are Interest-Paying Checking Accounts and How Do They Work? Most interest-paying checking accounts exhibit characteristics of both checking and savings accounts. Specifically, they earn relatively high rates of interest, especially compared with regular savings accounts, and allow relatively limited check-writing privileges. They are available through depository and nondepository institutions, including commercial banks, savings banks, credit unions, stock brokerage firms, mutual funds, and other financial services companies. What are some of...

  • In C++ Create an inheritance hierarchy that a bank might use to represent customers’ bank accounts. All customers at this bank can deposit (i.e., credit) money into their accounts and withdraw (i.e.,...

    In C++ Create an inheritance hierarchy that a bank might use to represent customers’ bank accounts. All customers at this bank can deposit (i.e., credit) money into their accounts and withdraw (i.e., debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction (i.e., credit or debit). Create an inheritance hierarchy containing base class Account and derived...

  • Textbook help its not in textbook solutions from the textbook C++ Programming 7th edition Malik,D.S Chapter...

    Textbook help its not in textbook solutions from the textbook C++ Programming 7th edition Malik,D.S Chapter 12 programming exercise 5 Banks offer various types of accounts, such as savings, checking, certificateof deposits, and money market, to attract customers as well as meet their specific needs. Two of the most commonly used accounts are savings andchecking. Each of these accounts has various options. For example, you mayhave a savings account that requires no minimum balance but has a lower interest rate....

  • (C++) How do I develop a polymorphic banking program using an already existing Bank-Account hierarchy? For each account...

    (C++) How do I develop a polymorphic banking program using an already existing Bank-Account hierarchy? For each account in the vector, allow the user to specify an amount of money to withdraw from the Bank-Account using member function debit and an amount of money to deposit into the Bank-Account using member function credit. As you process each Bank-Account, determine its type. If a Bank-Account is a Savings, calculate the amount of interest owed to the Bank-Account using member function calculateInterest,...

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