Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Banking Problem

Reply
Thread Tools

Banking Problem

 
 
ashu
Guest
Posts: n/a
 
      10-17-2005
hi to all,
Please read the following ques. first.

assume that a bank maintains 2 kinds of accounts for
customers one called as
savings accounts & other as current account.
the savings account provides simple interest &
withdraw facilities but no check book facilities.
the current account provides check book facilities but
no interest.
current account holders should also maintain a minimum
balance and if the minimum balance falls below this
level a service charge is to be imposed.

create a class account that stores customers name,
account no & type of account
from this class derive the classes current acc &
savings acc. to make them more
specific to their environments. include necessary
member functions in order to achieve following tasks:
1. accept the deposit from the customer and compute
the balance
2. display the balance
3. compute and deposit the interest
4. permit the withdrawl and update the balance
5. check the minimun balance, impose penalty if
necessary &update the balance

-->>DO NOT USE CONSTRUCTORS AND USE MEMBER FUNCTIONS
TO INITIALIZE THE CLASS MEMBERS

(NOTE: #MAKE AN EXTRA FIELD DATE (INCLUDE DOS.H TO
ACCESS DATE STRUCTURE)
#MAKE THIS PROGRAM BY USING LINK LIST )


The problem i am facing is that when i have created two derived class
as directed, i have to create two linklist to each derived class. So at
the time of modifing, depositing or any other operation, i have to
search both the linklist, which will be very time consuming & if no
such account exist, it would be the worst of the worst case. Then i
think another solution, i make another derived class by taking (saving
& current class) early derived class as base class & create a single
linklist. Now, the problem in that is, when my account is saving type,
my current class in totally untouched(wasted) & vice-versa.
I want to make a single linklist by merging two linklist. Would anyone
suggest me the solution. The program should be Menu Driven.

Thank You

 
Reply With Quote
 
 
 
 
mlimber
Guest
Posts: n/a
 
      10-17-2005
ashu wrote:
> hi to all,
> Please read the following ques. first.
>
> assume that a bank maintains 2 kinds of accounts for
> customers one called as
> savings accounts & other as current account.
> the savings account provides simple interest &
> withdraw facilities but no check book facilities.
> the current account provides check book facilities but
> no interest.
> current account holders should also maintain a minimum
> balance and if the minimum balance falls below this
> level a service charge is to be imposed.
>
> create a class account that stores customers name,
> account no & type of account
> from this class derive the classes current acc &
> savings acc. to make them more
> specific to their environments. include necessary
> member functions in order to achieve following tasks:
> 1. accept the deposit from the customer and compute
> the balance
> 2. display the balance
> 3. compute and deposit the interest
> 4. permit the withdrawl and update the balance
> 5. check the minimun balance, impose penalty if
> necessary &update the balance
>
> -->>DO NOT USE CONSTRUCTORS AND USE MEMBER FUNCTIONS
> TO INITIALIZE THE CLASS MEMBERS
>
> (NOTE: #MAKE AN EXTRA FIELD DATE (INCLUDE DOS.H TO
> ACCESS DATE STRUCTURE)
> #MAKE THIS PROGRAM BY USING LINK LIST )
>
>
> The problem i am facing is that when i have created two derived class
> as directed, i have to create two linklist to each derived class. So at
> the time of modifing, depositing or any other operation, i have to
> search both the linklist, which will be very time consuming & if no
> such account exist, it would be the worst of the worst case. Then i
> think another solution, i make another derived class by taking (saving
> & current class) early derived class as base class & create a single
> linklist. Now, the problem in that is, when my account is saving type,
> my current class in totally untouched(wasted) & vice-versa.
> I want to make a single linklist by merging two linklist. Would anyone
> suggest me the solution. The program should be Menu Driven.
>
> Thank You


See this FAQ:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.2

This newsgroup is for C++ language questions. If you have a specific
language-related question, we will be happy to help you. Otherwise, you
might want to try in comp.programming or
comp.please.do.my.homework.for.me.

Cheer! --M

 
Reply With Quote
 
 
 
 
Kai-Uwe Bux
Guest
Posts: n/a
 
      10-17-2005
mlimber wrote:

> ashu wrote:

[snip]
>> The problem i am facing is that when i have created two derived class
>> as directed, i have to create two linklist to each derived class. So at
>> the time of modifing, depositing or any other operation, i have to
>> search both the linklist, which will be very time consuming & if no
>> such account exist, it would be the worst of the worst case. Then i
>> think another solution, i make another derived class by taking (saving
>> & current class) early derived class as base class & create a single
>> linklist. Now, the problem in that is, when my account is saving type,
>> my current class in totally untouched(wasted) & vice-versa.
>> I want to make a single linklist by merging two linklist. Would anyone
>> suggest me the solution. The program should be Menu Driven.

[snip]
> This newsgroup is for C++ language questions. If you have a specific
> language-related question, we will be happy to help you. Otherwise, you
> might want to try in comp.programming or
> comp.please.do.my.homework.for.me.


Don't be so eager to dismiss this as off topic. Actually, there is a
language question in there: given two classes, deriving from a common base,
does C++ have a mechanism to have objects of both types in the same
container. If so, what is the recommended was to go about it?

And a possible answer is: you can use a container of pointers to the base
class. Better even, use a container of reference counting smart_pointers to
the base class so that memory management is still automatic.

To the OP: this should get you started. Post again when you have a draft of
your code and you are running into more serious problems. Also, please do
not roll your own code for the linked list. Use std::list<> instead. It
will save you serious headache.


Best

Kai-Uwe Bux
 
Reply With Quote
 
ashu
Guest
Posts: n/a
 
      10-17-2005
Thank you for considering my problem & guiding me so well. As i'm new
to the Oops, i not know much about Oops. So would you please tell me
what are containers of pointers, container of reference counting
smart_pointers???.

And "please do not roll your own code for the linked list. Use
std::list<> instead" ????? what does this line means. please tell me.

 
Reply With Quote
 
Kristo
Guest
Posts: n/a
 
      10-17-2005
ashu wrote:
> Thank you for considering my problem & guiding me so well. As i'm new
> to the Oops, i not know much about Oops. So would you please tell me
> what are containers of pointers, container of reference counting
> smart_pointers???.


Rather than have one of us explain it, I suggest picking up a good C++
book (or two) and reading it. IIRC, the FAQ has several good
recommendations.

> And "please do not roll your own code for the linked list. Use
> std::list<> instead" ????? what does this line means. please tell me.


It means that you should use the list class provided by the Standard
Library instead of writing your own.

Kristo

 
Reply With Quote
 
osmium
Guest
Posts: n/a
 
      10-18-2005
"ashu" writes:

> assume that a bank maintains 2 kinds of accounts for
> customers one called as
> savings accounts & other as current account.
> the savings account provides simple interest &
> withdraw facilities but no check book facilities.
> the current account provides check book facilities but
> no interest.
> current account holders should also maintain a minimum
> balance and if the minimum balance falls below this
> level a service charge is to be imposed.
>
> create a class account that stores customers name,
> account no & type of account
> from this class derive the classes current acc &
> savings acc. to make them more
> specific to their environments. include necessary
> member functions in order to achieve following tasks:
> 1. accept the deposit from the customer and compute
> the balance
> 2. display the balance
> 3. compute and deposit the interest
> 4. permit the withdrawl and update the balance
> 5. check the minimun balance, impose penalty if
> necessary &update the balance
>
> -->>DO NOT USE CONSTRUCTORS AND USE MEMBER FUNCTIONS
> TO INITIALIZE THE CLASS MEMBERS
>
> (NOTE: #MAKE AN EXTRA FIELD DATE (INCLUDE DOS.H TO
> ACCESS DATE STRUCTURE)
> #MAKE THIS PROGRAM BY USING LINK LIST )
>
>
> The problem i am facing is that when i have created two derived class
> as directed, i have to create two linklist to each derived class. So at
> the time of modifing, depositing or any other operation, i have to
> search both the linklist, which will be very time consuming & if no
> such account exist, it would be the worst of the worst case. Then i
> think another solution, i make another derived class by taking (saving
> & current class) early derived class as base class & create a single
> linklist. Now, the problem in that is, when my account is saving type,
> my current class in totally untouched(wasted) & vice-versa.
> I want to make a single linklist by merging two linklist. Would anyone
> suggest me the solution. The program should be Menu Driven.


First of all, a linked list is a very bad data structure for this problem,
it will be terribly slow and no reasonable amount of cleverness is going to
change that. That *might* be the point your instructor is trying to make.
He specifies you are not to use a meaningful constructor, and this is a
prelude to an obvious array solution, using hashing. Then, for a subsequent
assignment he has you already motivated for a better data structure.

I don't really understand everything you said, I suspect there is an English
problem. You seem to focus on the worst case, a customer who claims to have
an account in fact doesn't have one. Are you proposing three lists? And
some way to get the "customer" to answer some question or other truthfully?


 
Reply With Quote
 
Karl Heinz Buchegger
Guest
Posts: n/a
 
      10-18-2005

"osmium" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
>
> That *might* be the point your instructor is trying to make.


I think the point his instructor is trying to make is an exercise
on how to use a polymorphic class in a container (plus an exercise
in constructing a linked list, if he has to code the list by hand).

Never forget: This are class room assignments, not real world
applications.

--
Karl Heinz Buchegger


 
Reply With Quote
 
Jim Langston
Guest
Posts: n/a
 
      10-19-2005
"ashu" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...

> The problem i am facing is that when i have created two derived class
> as directed, i have to create two linklist to each derived class. So at
> the time of modifing, depositing or any other operation, i have to
> search both the linklist, which will be very time consuming & if no
> such account exist, it would be the worst of the worst case. Then i
> think another solution, i make another derived class by taking (saving
> & current class) early derived class as base class & create a single
> linklist. Now, the problem in that is, when my account is saving type,
> my current class in totally untouched(wasted) & vice-versa.
> I want to make a single linklist by merging two linklist. Would anyone
> suggest me the solution. The program should be Menu Driven.


Maybe this will get you started:

class Base
{
public:
virtual ~Base() {};
};

class Derived1 : Base
{
public:
~Derived1(){};
};

class Derived2 : Base
{
public:
~Derived2 () {};
};

int main()
{
Base* baseP1;
Base* baseP2;
baseP2 = new Derived1;
baseP2 = new Derived2;
};

What I'm showing here is that a base pointer can point to a derived object.
So a linked list of base objects can point to any derived objects of base.

Read your textbook on this.


 
Reply With Quote
 
ashu
Guest
Posts: n/a
 
      10-19-2005
here, the object of base class can't access the member data & functions
of derived class, as inheritance not work in opposite direction, so
can't help.

 
Reply With Quote
 
Karl Heinz Buchegger
Guest
Posts: n/a
 
      10-19-2005
ashu wrote:
>
> here, the object of base class can't access the member data & functions
> of derived class, as inheritance not work in opposite direction, so
> can't help.


Right. But the base class should not access all of this.

All your base class needs to do is:
make available a couple of virtual functions, which are
implemented in the derived classes.

Eg. The base class introduces functions for handling
of check books. In the 'current account' class, these
functions are fully implemented, while in the 'savings account'
class they are do-nothing-functions (or not implemented at all).

Virtual functions, paired with inheritance is the key to your
assignment!

--
Karl Heinz Buchegger
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Student Banking Problem rgt Java 10 04-24-2008 08:58 AM
ANZ banking problem with Opera 8.5 GraB NZ Computing 8 05-12-2006 08:19 AM
Firefox 1.0.4 ANZ online banking problem GraB NZ Computing 15 05-24-2005 11:38 AM
Can't Confirm Banking Transfers- Online Banking Bank of America (Firefox1.0) totsob Firefox 1 10-22-2004 10:19 PM
Firefox and online banking Hilary A Croughton Firefox 7 07-30-2004 02:00 PM



Advertisments