CISC 5350 Financial Programming (Spring 2011)

plumponionchipsSoftware and s/w Development

Nov 18, 2013 (3 years and 7 months ago)

106 views

CISC 5350 Financial Programming




(Spring 2011)

Final Exam and Project






Due Wednesday, May 11


Part 1

Q1) The three main concepts in Object Oriented Programming are: encapsulation, inheritance, and
polymorphism. Explain each in detail.


Q2
a) Explain
how a virtual function is used to c
reate run
-
time polymorphism.


Q2
b) What is the difference between a virtual function and a pure virtual function? What is an abstract
class?


Q3)

Give a brief definition / description of the following

data structures and
create a diagram to
demonstrate each
:

Stack (push and pop

operations
):

Queue (enqueue and dequeue

operations
):

Priority Queue (enqueue and dequeue operations):


Q4)

In a class called SortedList that creates and maintains a linked list of sorted nodes:


str
uct node{



int info;



node *next;

};


class SortedList

{


public:


SortedList();


~SortedList();


void insert(int x);


int getLength();




private:


bool exists(int x);


node * listBeg; //pointer to the beginning of your list


int length; //size of your list

};


Implement the function to insert an item into the list in its sorted position. To test if the item already is
in the list, you may use the function exists(int x), which returns true if the node is in the list.



void Sor
tedList::insert(int x)


{



}//insert



Q5)
Create SQL queries for *five* of the following on the banking database.



Banking database tables:

branch (branch_name, branch_city, assets)

customer (customer_name, customer_street, customer_city)

loan (loan_num
ber, branch_name, amount)

borrower (customer_name, loan_number)

account (account_number, branch_name, balance)

depositor (customer_name, account_number)


Q5a) List all loans.

Q5b) Find loan number, branch name, and the loan amount multiplied by 10% for ea
ch loan.

Q5c) Find the loan number of those loans with loan amounts between $500 and $50,000.

Q5d) Find all customers who have a loan, an account, or both.

Q5e) Find the number of depositors for each branch.

Q5f) Find the names of all branches where the

average account balance is more than $1,000.

Q5g) Find all customers who have both an account and a loan at the bank.


Q6
a
)

Choose
3

programs from the C++ for Financial Applications text by Ben Van Vliet, in Chapter 7
-

Financial Applications. Explain a
ll of the C++ programming features that are used and give the details of
how the function works and what is achieved.

Q6b) Choose one of the programs from Q6a) and incorporate the given function into an object oriented
program.


Part 2

Project
-

Choose on
e

of the following

programs
:

Option 1)

(Account Inheritance Hierarchy) Create an inheritance hierarchy that a bank might use to represent
customers' bank accounts. All customers at this bank can deposit (i.e., credit) money into their accounts
and withdraw

(i.e., debit) money from their accounts. More specific types of accounts also exist. Savings
accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand,
charge a fee per transaction (i.e., credit or debit).

Create a
n inheritance hierarchy containing base class
Account

and derived classes
SavingsAccount

and
CheckingAccount

that inherit from class Account. Base class Account should include one data member of
type double to represent the account balance. The class shoul
d provide a constructor that receives an
initial balance and uses it to initialize the data member. The constructor should validate the initial
balance to ensure that it is greater than or equal to 0.0. If not, the balance should be set to 0.0 and the
cons
tructor should display an error message, indicating that the initial balance was invalid. The class
should provide three member functions. Member function credit should add an amount to the current
balance. Member function debit should withdraw money from
the Account and ensure that the debit
amount does not exceed the Account's balance. If it does, the balance should be left unchanged and the
function should print the message "Debit amount exceeded account balance." Member function
getBalance should return

the current balance.

Derived class SavingsAccount should inherit the functionality of an Account, but also include a data
member of type double indicating the interest rate (percentage) assigned to the Account.
SavingsAccount's constructor should receive
the initial balance, as well as an initial value for the
SavingsAccount's interest rate. SavingsAccount should provide a public member function
calculateInterest that returns a double indicating the amount of interest earned by an account. Member
function
calculateInterest should determine this amount by multiplying the interest rate by the account
balance. [Note: SavingsAccount should inherit member functions credit and debit as is without
redefining them.]

Derived class CheckingAccount should inherit from

base class Account and include an additional data
member of type double that represents the fee charged per transaction. CheckingAccount's constructor
should receive the initial balance, as well as a parameter indicating a fee amount. Class CheckingAccoun
t
should redefine member functions credit and debit so that they subtract the fee from the account
balance whenever either transaction is performed successfully. CheckingAccount's versions of these
functions should invoke the base
-
class Account version to
perform the updates to an account balance.
CheckingAccount's debit function should charge a fee only if money is actually withdrawn (i.e., the debit
amount does not exceed the account balance). [Hint: Define Account's debit function so that it returns a
bo
ol indicating whether money was withdrawn. Then use the return value to determine whether a fee
should be charged.]

After defining the classes in this hierarchy, write a program that creates objects of each class and tests
their member functions. Add inter
est to the SavingsAccount object by first invoking its calculateInterest
function, then passing the returned interest amount to the object's credit function.

Option 2)

Expand the employee payroll program to include
an
Employee

base class and s
ub classes fo
r
H
ourly

based and
S
alary

based employees (Of course you should build on the program you have already
created in the assignments). This program includes an array of employees, inheritance, and
polymorphism for salary computation. Define the class hierarchy

and include the appropriate data
members, member functions, and access modifiers for each class. All employees will have the following
information: id, name, gross pay, tax amount, and net pay. Hourly based employees will contain
information for
hours wor
ked and hourly rate, while salary based employees will contain a value for
yearly salary. For salary based employees, to find the regular (gross) pay for a week, divide the salary by
52. For simplicity, you may use a constant tax rate of 30% to compute the

tax amount. The program
should find the average, minimum, and maximum gross pay of all employees.