Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cs-142:pretend-banking [2015/01/07 15:59] (current)
ryancha created
Line 1: Line 1:
 +=Purpose=
  
 +The purpose of this lab is to build a program with multiple classes as well as use the other skills you have picked up over the last few weeks. Note that in this lab you will be graded on your choices of how you break the problem up into small and meaningful pieces. Please make several nice, small, natural classes and methods.
 +
 +Note to more advanced students: As noted above you will be graded on your choices of how you break the problem up into small and meaningful pieces. The TA's have been instructed NOT to be impressed that you found a way to code the entire lab in just three very complex lines, as impressive as that might be!
 +
 +=Requirements=
 +
 +You will write a program that computes the total value of a portfolio for '''​pretend customers'''​ at a bank.
 +
 +Your code will read data for the portfolio from a data file. You will prompt the user for the needed file name.
 +
 +There may be three kinds of '''​assets'''​ in the customers account:
 +
 +# '''​Checking accounts'''​ each with a name and an associated balance
 +# '''​Bonds'''​ each with a name, year of issue, initial value, and a rate of return
 +# '''​IRA-Bonds'''​ each with a name, year of issue, initial value, and a rate of return
 +
 +This will look something like this:
 +
 + ​customer Kevin
 + ​checking myaccount 100.00
 + bond mybond1 1997 100 0.07
 + bond mybond2 2010 200 0.01
 + ​irabond myirabond1 1997 100 0.06
 + end
 + ​customer Mark
 + ​irabond hisirabond1 1999 200 0.08
 + bond hisbond1 1990 2000 0.10
 + end
 + 
 +There are two pass-off files. Please download both([http://​dna.cs.byu.edu/​~norkish/​pass-off.txt 1] and [http://​dna.cs.byu.edu/​~norkish/​pass-off2.txt 2]). The second file should make it easy for you to tell where your program might be making mistakes.
 +===Example explained===
 +"​customer Kevin" means that there is a customer named Kevin and that his data will follow this line
 +
 +"​checking myaccount 100.00"​ means that Kevin has a checking account called "​myaccount"​ containing $100.00.
 +
 +"bond mybond1 1997 100 0.07" means that Kevin holds a bond called "​mybond1"​ purchased in 1997 for $100.00 that earns 7% interest per year.
 +
 +"​irabond myirabond1 1997 100 0.06" means that Kevin holds a tax free bond called "​myirabond1"​ purchased in 1997 for $100.00 that earns 6% interest per year.
 +
 +Note that, as shown, the customer may have multiple assets of each type.
 +
 +"​end"​ indicates the end of a customer portfolio (there is no more information for Kevin).
 +
 +"​customer Mark" means that there is another customer named Mark and his data will follow.
 +
 +==Computing Value==
 +The value of checking accounts is just the balance given for the account in the file.
 +
 +The value of an irabond is the purchase amount plus interest compounded annually (don't include 2011, that is, if a bond was purchased in 2011, there will be no interest on it yet). See pages 132-138 for an example. You can think of it simply as a loop where each iteration (i.e. each year) your value goes up like this (make sure you don't modify the original value in calculating interest!):
 + ​valuePlusInterest = valuePlusInterest * (1.0 + rate)
 +
 +The value of a bond is the purchase amount plus interest compounded annually (just like above) MINUS 30% of the interest (taxes). Note that taxes aren't taken out annually, only when the bond is cashed (this affects the interest you earn). Mathematically that would be:
 + ​cashValue = valuePlusInterest - (.3 * (valuePlusInterest - value) )
 +
 +Once you have read in all of the data, allow your user to type the name of a customer. If the customer exists, print out the customer name, the portfolio value and all of the items in the portfolio with their individual values. Allow the user ask about names until they enter "​stop"​.
 +
 +As you did in the previous labs, write some test cases. These should start very small and simple but progressively become more complex. You will use these to test that your program does what it is supposed to.
 +
 +=Example Output=
 +
 +Your program should allow the user to give an account name for which the assets and total portfolio value will be printed. If we put the data from the example above in a file "​example.txt",​ we might picture seeing something like this as the output:
 +
 + ​Please,​ dear user, a file name:​example.txt
 + ​Loading example.txt.......... done
 + ​Customer name (or "​stop"​):​ Kevin
 + ​Customer Name: Kevin Total Portfolio Value: 737.99
 + ​ Checking:​ myaccount Value: 100.00
 + ​ Bond:​ mybond1 Year: 1997 Value: 100.00 Rate: 0.07
 + ​ Bond:​ mybond2 Year: 2010 Value: 200.00 Rate: 0.01
 + ​ IRABond:​ myirabond1 Year: 1997 Value: 100.00 Rate: 0.06
 + 
 + ​Customer name (or "​stop"​):​ Mark
 + ​Customer Name: Mark Total Portfolio Value: 11463.98
 + ​ IRABond:​ hisirabond1 Year: 1999 Value: 200.00 Rate: 0.08
 + ​ Bond:​ hisbond1 Year: 1990 Value: 2000.00 Rate: 0.10
 + 
 + ​Customer name (or "​stop"​):​ stop
 + Peace out!
 +
 +=Think before programming=
 +
 +You can assume that no two customers in the file will have the same name and no two assets for a customer in the file will have the same name.
 +
 +The point of this lab is for you to make classes. We are expecting you to make classes for the customers, and the various kinds of assets. And since you just learned about inheritance,​ '''​you should use inheritance'''​ where it makes sense (the assets). '''​You will need to use virtual functions'''​ (each asset will compute its current value in a different way) and a vector of asset pointers (see the [[Animals]] example for help). I would rather not say more that that here. This is the kind of problem you should be able to sort out now. So give it a try. If you get really stuck see a TA.
 +
 +=Pass-off procedure=
 +{{see|How to pass off}}
 +
 +When you have your program working, you will need to show it to a TA. The TA will evaluate your code based on the following criteria:
 +# Create your own test case file that thoroughly tests your code. (3 points)
 +# Proper formatting, good variable naming, and comments. (3 points)
 +# As you start to write a program, start with small simple steps. Note that you do not have to show the TA each step individually. The TA will simply check that your program accomplishes each of these elements:
 +## Prompt the user for the name of the portfolio file. (2 points)
 +## Read the lines of data from the portfolio file and identify each line as customer, irabond, checking, or bond. (2 points)
 +## Create a Customer class. (3 points)
 +## Create an instance of the Customer class for each new customer in the file. (3 points)
 +## Create classes for each asset class (Checking account, Bond, Irabond) which inherit from an "​Asset"​ class (class names should be singular and start with a capital letter). (1 point for each class for 4 total points)
 +## Create the corresponding objects for each asset in the file (irabond, checking, or bond). (3 points)
 +## Put the customers in a vector, put the assets in a '''​single'''​ vector of asset pointers in the customer object. (3 points)
 +## Repeatedly prompt (until user enters '​stop'​) for a customer name and print out all of the assets and the total value of the portfolio for the customer. (3 points)
 +## Accurate calculation of customer portfolios using classes and member functions. Include values of each asset and total value of portfolio. (3 points)
 +
 +
 +Extra credit:
 +
 +(2 point) Financial institutions do not compute interest in a loop. There is a formula for this. Look it up and use it. Compare the result to the loop version to assure it is right (print out the value for both computed values). Note that the formula depends on how ''​often''​ the interest is "​compounded"​. You will have to add another item to the bond lines in the file for this.
cs-142/pretend-banking.txt ยท Last modified: 2015/01/07 15:59 by ryancha
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0