| | |
C++ Bank account - help!!
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2009
Posts: 9
Reputation:
Solved Threads: 0
This what I have from my last assignment on creating a bank account. This is what i have to add for the next assignment and I'm lost. Can someone please help me do this!!
Assignment:
1. Create 3 subclasses that inherit from the bank account class created in homework 3. They are Checking, Savings, and CD.
For Checking:
Override the debit method, there is now a per check fee. When we debit money charge a processing fee each time. Account type is “CH”.
For Savings:
Add a private static member for interest rate. Add a method that will calculate the monthly interest and add it to the balance. Also implement a minimum balance check. This should run the same time as the monthly interest, if the account has less than $250, then there is a $5 maintenance fee that should be deducted from the balance.
For CD:
Add a private static member for the interest rate. Add a member to keep track of the number of debits. This account has a limit of 3 withdrawals per year. After the 3rd withdrawal, there is a 2% transaction fee (min $5) for each withdrawal. Add a method that will rollover the account, which indicates that a year has passed, the CD has reached its term, so we will reset the withdrawal count and apply the annual interest rate.
2. Test the new classes as before, create an array of BankAccount objects, assign the elements of the array to new elements of the different classes that we have. Call all of the methods making use of polymorphic behavior that we have for our debit and credit methods.
Assignment:
1. Create 3 subclasses that inherit from the bank account class created in homework 3. They are Checking, Savings, and CD.
For Checking:
Override the debit method, there is now a per check fee. When we debit money charge a processing fee each time. Account type is “CH”.
For Savings:
Add a private static member for interest rate. Add a method that will calculate the monthly interest and add it to the balance. Also implement a minimum balance check. This should run the same time as the monthly interest, if the account has less than $250, then there is a $5 maintenance fee that should be deducted from the balance.
For CD:
Add a private static member for the interest rate. Add a member to keep track of the number of debits. This account has a limit of 3 withdrawals per year. After the 3rd withdrawal, there is a 2% transaction fee (min $5) for each withdrawal. Add a method that will rollover the account, which indicates that a year has passed, the CD has reached its term, so we will reset the withdrawal count and apply the annual interest rate.
2. Test the new classes as before, create an array of BankAccount objects, assign the elements of the array to new elements of the different classes that we have. Call all of the methods making use of polymorphic behavior that we have for our debit and credit methods.
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <string> using namespace std; class BankAccount { private: static int number; int AcctNumbr; string OwnerName; string Accounttype; double CurrentBalance; public: //void BankAccount::withdraw (double amount) BankAccount(void); BankAccount( string , double ) ; void withdraw( double ); double getBalance() const; }; int BankAccount::number = 1001; BankAccount::BankAccount( void ) { } BankAccount::BankAccount( string OwnerName, double balance ) // You have an overloaded constructor here but no prototype in class definition { cout << "default constructor."; Accounttype = "GA"; CurrentBalance = balance; this ->OwnerName = OwnerName; } void BankAccount::withdraw (double amount) // Good for debit method but where is it in the class definition? { if( amount > 0 && CurrentBalance >= amount ) { CurrentBalance -= amount; } } double BankAccount::getBalance() const { return CurrentBalance; } int main () { BankAccount bankList[10]; int nextAcntIndex = 0; string name; double balance; int Accountnumber; int Withdrawl; cout << " Welcome to World Bank " << endl; int choice; do { system("cls"); cout << endl; cout << " United Bank" << endl; cout << " Select a menu option" << endl; cout << " 1. Creating an Account" << endl; cout << " 2. Debt" << endl; cout << " 3. Current Balance " << endl; cout << " 4. credit " << endl; cout << " 5. Exit " << endl; cout << endl; cout << " Enter your choice by using the numbers -->> "; cin >> choice; cin.clear(); cin.ignore( INT_MAX, '\n' ); switch( choice ) { case 1: system( "cls" ); cout << "Enter your name: "; cin >> name; cout << "Enter your balance: "; cin >> balance; bankList[nextAcntIndex] = BankAccount( name, balance); nextAcntIndex++; break; case 2: system( "cls" ); cout << "Enter Account number; "; cin >> Accountnumber; cout << "Enter Withdrawl; "; cin >> Withdrawl; bankList [Accountnumber - 10001].withdraw ( Withdrawl ); break; case 3: cout << " Enter Account number; "; cin >> Accountnumber; cout << "Currentbalance" << bankList [Accountnumber - 10001].getBalance (); break; case 4: cout << "Enter Account number; "; cin >> Accountnumber; cout << "Enter balance; "; cin >> balance; break; case 5: default: cout << "That wasn't a choice"; break; } } while( choice !=5 ); return 0; }
Last edited by John A; Jul 31st, 2009 at 12:36 am. Reason: added code tags
•
•
Join Date: Jan 2008
Posts: 3,837
Reputation:
Solved Threads: 503
You've posted no new code. You have no inheritance in the program and presumably still don't, so presumably you don't understand it yet. You can't do it without it. Your last several posts give no clue about what the problem is, so the only advice one can give is "find a tutorial on inheritance and follow it". Type in "c++ inheritance tutorial". There are lots of them. The only other thing we could do here is simply do it for you and post it, which can't/won't/shouldn't happen.
Last edited by VernonDozier; Aug 4th, 2009 at 1:08 am.
This is how to do inheritance`:
The interface of BankAccount class would be public , so the outside
world would get to use them.
Now you should implement, the needed functions in checkings,
savings and CD class. The needed functions are described in your
notes in the first post.
Continue from this , let me know how it goes.
C++ Syntax (Toggle Plain Text)
class BankAccount { ... } //base class class Savings : pubilc BankAccount { ... } //saving derives from base class Checking : public BankAccount { ... } //checking derives from base class CD : public BankAccount { ...}
The interface of BankAccount class would be public , so the outside
world would get to use them.
Now you should implement, the needed functions in checkings,
savings and CD class. The needed functions are described in your
notes in the first post.
Continue from this , let me know how it goes.
![]() |
Similar Threads
- Design a class named BankAccount to hold the following data for a bank account: (Java)
- Bank Account for Hish Risk IBC (eCommerce)
- HOT Niche Guaranteed Bank Account Site (Websites for Sale)
- Another Bank Account class (C++)
- Bank Account class (C++)
- Help Needed With OOP Bank Account..VB.Net (VB.NET)
- Bank Account ===>Need help >.< Thk (C++)
- Unable to view yahoo mail or online bank account etc (Viruses, Spyware and other Nasties)
- Bank account class (C++)
Other Threads in the C++ Forum
- Previous Thread: Read Something That is in a Parenthesis
- Next Thread: C++ Encryption problem
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






