VUSuperior Chat Room

Thursday, 5 February 2015

CS304 Object Oriented Programming Assignment No. 03 Solution And Discussion Semester Fall 2014 Due Date 11 Feb, 2015

Assignment No. 03
Semester: Fall 2014
CS304: Object Oriented Programming
Total Marks: 20
Due Date: 11/02/2015

Instructions:

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: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted and will be awarded with zero marks. For example, if you submit code in .doc (Microsoft Word Document) or .txt files or .exe file, no reward will be given in any case.


Objective:

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

§  Inheritance
§  Virtual functions
§  Polymorphism



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.



For any query about the assignment, contact at cs304@vu.edu.pk




Assignment 


Problem Statement
  
In this assignment you will be modeling a part of simple banking system. In this banking system, there are three classes, Account, Current Account and Saving Account. Current and Saving Account classes are inherited from the Account class. Account is the abstract class whereas Current and Saving Account are the concrete classes.

Account class has the following data members:
  • Account No.
  • Current Balance
  • Bank name
  • Branch code
  • Interest rate


Account class must have the following member functions:

Functions
Description
Account(float, int, char *, int, int)
Parameterized constructor will take balance, account no, bank name, branch code and interest rate as arguments and set their values accordingly
setBalance(float);
It will set the value of balance with the value of passed argument
getBalance()
It will return the value of available balance
getInterestRate()
It will return interest rate
calcProfit()
It will calculate the profit based on the interest rate

Current Account class must have the following member functions:

Functions
Description
currentAccount(float, int, char *, int, int  = 0)
Parameterized constructor will take balance, account no, bank name, branch code and interest rate as arguments and initializes data members of base class through base initializer list
calcProfit()
It will calculate the profit based on the interest rate and display the profit and current balance after profit


Profit in case of Current Account will be 0 as there is no profit on Current Account.



Saving Account class must have the following member functions

Functions
Description
savingAccount(float, int, char *, int, int  = 0)
Parameterized constructor will take balance, account no, bank name, branch code and interest rate as arguments and initializes data members of base class through base initializer list
calcProfit()
It will calculate the profit based on the interest rate

Profit in case of Saving Account = (Current Balance * interest rate)/100
Current Balance = Current balance + profit

Within main() function, create an array containing Account objects, calculate profit polymorphically(according to Account object) and generate information.

You can create object as follow:

currentAccount(10000, 01, "UBL", 123);
currentAccount(15000, 01, "HBL", 111);
savingAccount(15000, 02, "HBL", 111, 10);
savingAccount(10000, 02, "UBL", 123, 15);
currentAccount(25000, 03, "HBL", 111);

Sample output of the program:



1 comments: