Fall 2014_CS304_2

download Fall 2014_CS304_2

of 4

Transcript of Fall 2014_CS304_2

  • 8/10/2019 Fall 2014_CS304_2

    1/4

    Assignment No. 02

    Semester: Fall 2014

    CS304: Object Oriented Programming

    Total ar!s: 20

    "#e "ate: 0$%12%2014

    &nstr#ctions:

    Please read the following instructions carefully before submitting assignment. It should be clear that your

    assignment will not get any credit if:

    The assignment is submitted after due date.

    The submitted assignment does not open or file is corrupt.

    Assignment is copied(partial or full) from any source (websites, forums, students, etc)

    Note:ou ha!e to upload only .c'' (ile. Assignment in any other format (e"tension) will not be accepted and wi

    be awarded with #ero mar$s. %or e"ample, if you submit code in .doc (&icrosoft 'ord ocument) or .t"t fileor .e"e file, no reward will be gi!en in any case.

    Objecti)e:

    The obecti!e of this assignment is to pro!ide hands on e"perience of:

    *elationships among classes

    +onstructors

    +onstructor o!erloading

    etter and -etter functions

    *#idelines:

    +ode should be properly indented and well commented.

    %ollow ++// guide lines while writing !ariable names, function names etc

    0se only de!1+// for this assignment.

    For an+ ,#er+ abo#t t-e assignment contact at cs304/)#.ed#.'!

    Assignment

    mailto:[email protected]:[email protected]
  • 8/10/2019 Fall 2014_CS304_2

    2/4

    Problem Statement:

    In this assignment you will be modeling a part of simple ban$ing system. In this system, there are two classes

    +ustomer and Account which are related to each other !ia aggregation relationship.

    Account class has the following data members:

    Account No.

    +urrent 2alance

    2an$ name

    2ranch code

    Account class must ha!e the following member functions:

    F#nction "escri'tion

    Account() efault constructor for account class, setting account balance to 3,

    Account number to 4, branch name to N055 and branch code to 3

    Account(float, int, char 6,

    int)

    It will ta$e balance, account no, ban$ name and branch code as

    arguments and set their !alues accordingly

    withdraw(float) This will subtract amount from the balance of account that will be

    passed as its parameter.

    If the amount being withdrawn is greater the balance of the account

    , it will display the message 7Insufficient balance8

    deposit(float) %unction will add amount to the balance of account. Amount will

    be passed as its parameter.

    get2alance() This function will return the !alue of a!ailable balance

    getAccountNo() This function will return the account number

    get2an$Name() This function will return the name of ban$

    get2rach+ode() This function will return branch code of ban$

    +ustomer class has the following data members:

  • 8/10/2019 Fall 2014_CS304_2

    3/4

    +ustomer Name

    Address

    Account obect

    +ustomer class must ha!e the following member functions:

    F#nction "escri'tion

    display() This function will display the !alues of all data members

    of +ustomer and Account class

    Parameteri#ed constructor It will ta$e Account, name and address as a arguments and

    set their !alues accordingly

    'ithin main() function, obects of both classes will be created , and respecti!e member functions of these obectwill be called.

    %irst of all create an obect of Account class by passing balance, account number, ban$ name and branch codeThen create an obect of customer class by passing Account obect, name and address. Now call display() functio

    which will display all the !alues of +ustomer including hisher name, address and account detail.

    The program should prompt the user to enter a !alue and call deposit() function passing it entered !alue. Then ca

    the display() function.

    After this, the program should prompt the user to enter a !alue and call withdraw() function passing it entere

    !alue. Then call the display() function.

    Sam'le o#t'#t o( t-e 'rogram:

  • 8/10/2019 Fall 2014_CS304_2

    4/4

    ST OF C5