CS304 Object Oriented Programming Assignment 02 Solution and Discussion Fall 2014 Due Date: Dec 08, 2014



Objective:



The objective of this assignment is to provide hands on experience of:

Sponsored Links



Relationships among classes
Constructors
Constructor overloading
Getter and Setter functions
Guidelines:



Code should be properly indented and well commented.
Follow C/C++ guide lines while writing variable names, function names etc
Use only dev-C++ for this assignment.


Assignment


Problem Statement:

m.jpg

ccount()
Default constructor for account class, setting account balance to 0, Account number to 1, branch name to NULL and branch code to 0
Account(float, int, char *, int)
It will take balance, account no, bank name and branch code as arguments and set their values 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 “Insufficient balance”
deposit(float)
Function will add amount to the balance of account. Amount will be passed as its parameter.
getBalance()
This function will return the value of available balance
getAccountNo()
This function will return the account number
getBankName()
This function will return the name of bank
getBrachCode()
This function will return branch code of bank
Customer class has the following data members:

Customer Name
Address
Account object


Customer class must have the following member functions:


Untitled.jpg

Within main() function, objects of both classes will be created , and respective member functions of these objects will be called.



First of all create an object of Account class by passing balance, account number, bank name and branch code. Then create an object of customer class by passing Account object, name and address. Now call display() function which will display all the values of Customer including his/her name, address and account detail.



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



After this, the program should prompt the user to enter a value and call withdraw() function passing it entered value. Then call the display() function.



Sample output of the program:

s2 (1).jpg