473,387 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Question about Bank account c++ with derived classes

Need some helps here >.<

[code]The project i required to complete :
Create a base class Bank of a bank account with member functions to allow withdrawal, deposit and calculation of balance. Account should have a name, account number and type.

Create derived class Saving of a saving account, which allows overdraft up to $8000 and gives interest of 2% per annum. Create another derived class Current of a current account, which does not allow overdraft and does not give any interest.

Create two objects of the derived classes with initial deposits of $2000 and $5000 each. Demonstrate the use of various member functions for withdrawal, deposit, interest calculation for one month, showing balance and giving warning when the account balance is zero or less.

The display can be as given below (user inputs are in bold):



Account Name: Jacky Chan(in bold)
Account No: 12345(in bold)
Type: Saving
Balance: $6000
Enter positive amount to deposit and negative to withdraw: $1000(in bold)
Balance: $7000
Interest next month: $11.67


The program that i have wrote so far :

#include <iostream>
#include <string>
using namespace std;
class Bank
{
private:
string myname;
int number;
double changes;
double initialbal;
double endingbal;
public:
Bank(string name=" ", int num=0, double c=0, double ibal=0, double ebal=0)
{
myname = name;
number = num;
changes = c;
initialbal = ibal;
endingbal = ebal;
}
void EnterName();
void ShowName(void );
void EnterNumber();
void ShowNumber(void );
void EnterChanges();
void ShowChanges(void );
void EnternComputeInitialBal(double );
void ComputeEndinglBal(double );
};
void Bank::EnterName()
{
cout<<"Please enter your Account Name: ";
getline(cin, myname);
}
void Bank::ShowName()
{
cout<<"\n\nAccount Name: "<<myname<<endl;
}
void Bank::EnterNumber()
{
cout<<"Please enter your Account Number: ";
cin>>number;
}
void Bank::ShowNumber()
{
cout<<"Account No: "<<number<<endl;
}
void Bank::EnterChanges()
{
cout<<"Please enter positive amount to deposit and negative to withdraw: $";
cin>>changes;
}
void Bank::ShowChanges()
{
cout<<"Enter positive amount to deposit and negative to withdraw: $"<<changes<<endl;
}
void Bank::EnternComputeInitialBal(double ibal)
{
cout<<"Enter inital balance : $"<<ibal<<endl;
}
void Bank::ComputeEndinglBal(double ibal)
{
endingbal=ibal+changes;
cout<<"Ending balance : $"<<endingbal<<endl;
}
void main()
{
Bank bank;
bank.EnterName();
bank.EnterNumber();
bank.EnterChanges();
bank.ShowName();
bank.ShowNumber();
cout<<"Type: Saving "<<endl;
bank.EnternComputeInitialBal(6000);
bank.ShowChanges();
bank.ComputeEndinglBal(6000);
cout<<"Interest next month: $11.67"<<endl;
cout<<"\n\n\n ^_^ Thank you for using this program ^_^ "<<endl;
cout<<" Have a nice day "<<endl;
}
[code]
The problem i have is the derived classes "Saving" and "Current" for my program , Any helps will be greatly appreciated. Thanks in advance.
Jul 22 '07 #1
2 4313
weaknessforcats
9,208 Expert Mod 8TB
Do you have a class diagram?

That is, have you designed on paper what your system does.

If not, try some CRC (Class-Responsibility-Client) cards.

CRC cards are 3x5 file cards with the name of the class as the title on the front. Below that, the card is dividded into two columns in labeled Resonsibility and the other named Client.

Your member functions are the class Responsibilities and the Client is what class either procides are receives information from this method.

The back of the card has the names of the class provate data members.

These cards work for programs of about 50 classes or less. Bigger programs require more powerful tools.

If you don't use these cards, at least draw a class diagram on a sheet of paper. The classes should eb represented by rectangles divided into three parts. The top part for thew class name, the middle part for the class methods and the bottom part for the private members. The rectangles are connected to the other rectangles with lines and the lines are labeled with info about what the relationship is.

What I see in your Bank class is much more than a bank. It also has the screen format and the data entry code. None of this should be in the Bankj class. A Bank is a Bank and not a Bank+screen manager+keyboard.

Start with a Bank as a container of accounts.
An account is a container of transactions
A trancaction can be a cash withdrawal, deposit, check.

Good luck.
Jul 22 '07 #2
Hi weaknessforcats , thanks for the reply . I understand what you trying to said in the reply . Maybe i should rewrite my program >.< I think i messed it up . BTW I still have doubts how can i create the derived classes "Saving" and "Current" for my program. Can show someone show me or explain to me how I can get it work for my program . Thanks in advance
Jul 23 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Stefan Reiter | last post by:
Hi, I am trying to validate bank numbers ( the number that identifies a bank) and bank account numbers. Is there a certain algorithm or do you know any generell rules like how long the...
8
by: Generic Usenet Account | last post by:
To settle the dispute regarding what happens when an "erase" method is invoked on an STL container (i.e. whether the element is merely removed from the container or whether it also gets deleted in...
1
by: Amos | last post by:
Dear Sirs I am trying to build a cash flow software, first I thought to build one table for each cash and bank account, but talking to some people they suggested me to build one unique table for...
8
by: codymanix | last post by:
Hi! I have a class Bank and a Class BankAccount. A Bank can contains multiple BankAccounts (logical, isn't it?). The central Bank object contains a datatable which holds the data of all...
5
by: perspolis | last post by:
hi everyone In my accounting database ,there are several account like Persons,Banks,.... I design them in separated table. in your opinion ,it's better to have all in one table or separated...
2
by: pauldepstein | last post by:
Suppose I have a class of objects which take an integer parameter. I can easily create an object with the required parameter as follows: name_of_class variable_name(integer_value); For...
4
by: Chris | last post by:
Hi all, I can serialize and deserialize a single class, but I'm wondering if it's possible to serialize/deserialize different class types in the same file? For example, I have a base class, and...
9
by: Mike Hofer | last post by:
In a large application I'm working on (ASP.NET 1.1, VS2003), we have a base class that wraps stored procedures. Essentially, this base class (StoredProcedureBase) encapsulates the code to set up...
4
by: automode | last post by:
can someone kindly help me with this program.PLEASe Create a base class Bank of a bank account with member functions to allow withdrawal, deposit and calculation of balance. Account...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.