Starting from:

$15

Laboratory Exercise Week 7 solution

Task One: Debugging
Download Paintings.cpp from the subject website. The program contains various errors; syntax, logical and/or with respect to the sample output, which can be found in Paintings.txt.
The Paintings.txt output was produced by running ./Paintings < Input_Paintings.txt
Assume that Paintings is the executable produced by compiling the corrected Paintings.cpp.
Task Two: Inheritance
Consider the following UML diagram.
Define and implement the classes shown in the diagram above in files Bank.h and Bank.cpp.
Implement main() and other functions in task2Main.cpp, create instances of accounts for
customers of follows:
 Alice has a saving account, BSB# is 123456, account# is 12345678, address is
Northfields Avenue, Wollongong, phone# is 1234567, and balance is $1000, saving card number 1234567890123456.
 Bob has a credit card account, BSB# is 123123, Account# is 12341234, address is 20 Moore Street, North Wollongong, Phone# is 12341234, balance is $1000 debt, credit card# is 0987654321123456, limitation $2000, due by 20 April 2014.
To make it simple, assume it is the end of the month, every month has 30 days, no matter it is February or March, every year has 360 days. The member function interest() calculates interests for the above accounts according to the following algorithms, and change the balances of those accounts. 0.5 cents or over shall be round up to 1 cent.
Assume it is end of the month.
 Interest rate for a saving account is 0.3% per year. Add the interest to the balance of saving account every month. Use following expression to compute interest for a saving account (A month has 30 days):
interest-rate-per-day = 0.3% / 360,
interest = balance * interest-rate-per-day * 30.
 If the credit card over due days less than or equals to 15 days, interest rate is 12.5% per year, 18% per year for overdue more than 15 days. Add interest to the account. Use the following expressions to compute the penalty interest for a credit card account:
There are 10 days expired from 20/04/2014 to the end of the month. The interest rate is 12.5% per year.
interest-rate-per-day = 12.5% / 360,
interest = balance * interest-rate-per-day * 10.
Compile the files by
CC –o interest.exe task2Main.cpp Bank.cpp
And execute
./interest.exe
The output details are following:
BSB#: 123456, Account#: 12345678, Alice, Saving, Card#: 1234567890123456, Balance:
$1000.25 CR, Interest paid: $0.25
BSB#: 123123, Account#:12341234, Bob, Credit, Card#: 0987654321123456, Balance:
$1003.47 DR, Interest charges: $3.47

More products