473,799 Members | 3,161 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about Bank account c++ with derived classes

2 New Member
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(voi d );
void EnternComputeIn itialBal(double );
void ComputeEndinglB al(double );
};
void Bank::EnterName ()
{
cout<<"Please enter your Account Name: ";
getline(cin, myname);
}
void Bank::ShowName( )
{
cout<<"\n\nAcco unt Name: "<<myname<<endl ;
}
void Bank::EnterNumb er()
{
cout<<"Please enter your Account Number: ";
cin>>number;
}
void Bank::ShowNumbe r()
{
cout<<"Account No: "<<number<<endl ;
}
void Bank::EnterChan ges()
{
cout<<"Please enter positive amount to deposit and negative to withdraw: $";
cin>>changes;
}
void Bank::ShowChang es()
{
cout<<"Enter positive amount to deposit and negative to withdraw: $"<<changes<<en dl;
}
void Bank::EnternCom puteInitialBal( double ibal)
{
cout<<"Enter inital balance : $"<<ibal<<en dl;
}
void Bank::ComputeEn dinglBal(double ibal)
{
endingbal=ibal+ changes;
cout<<"Ending balance : $"<<endingbal<< endl;
}
void main()
{
Bank bank;
bank.EnterName( );
bank.EnterNumbe r();
bank.EnterChang es();
bank.ShowName() ;
bank.ShowNumber ();
cout<<"Type: Saving "<<endl;
bank.EnternComp uteInitialBal(6 000);
bank.ShowChange s();
bank.ComputeEnd inglBal(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 4343
weaknessforcats
9,208 Recognized Expert Moderator Expert
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 Responsibilitie s 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+keyboar d.

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
cheongsiwei
2 New Member
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
6636
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 numbers have to be at least /most?
8
2217
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 the process), I looked up the STL code. Erase certainly does not delete the memory associated with the element. However, it appears that the destructor on the element is invoked. I wonder why it has to be this way. In my opinion, this renders...
1
495
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 all bank and cash accounts, putting one more column to identify each bank or cash account. The unique table has this columns structure: ID Date B/C account FinCode Description Debit Credit
8
1273
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 bankaccounts. This means, the class BankAccount must have access rights to the datatable in Bank, but I don't want to expose the datatable as a public property. Since C# does not support friend classes, what is the best solutuion for
5
376
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 table?? thx in advance
2
1263
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 clarity, suppose I have a bank-account class and each object falls into one of 5 distinct categories. Then I might have code like:
4
1685
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 3 classes derived from it. Instances of these 3 classes are stored in a List<baseclass>. I'd like to be able to save the objects in List<>, and later reload them. Is this possible? I can write each object to the same file by using a different...
9
1505
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 the connection, transaction, command and parameters required to invoke a stored procedure on our SQL Server database. It provides helper methods that simplify the process of invoking the stored procedure so that our data access classes can make the...
4
4115
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 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...
0
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10251
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10228
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.