A bank wants to show its customers how their savings will grow if they
invest in a Guaranteed Investment Certificate (GIC).
It is assumed that the customer starts with $1000.
The bank's GIC plan has three interest rates, depending on the number
of years that the GIC is held.
The file /usr/copy/aps105/gicrates.t contains the code that does most of this. There are three modules that do not exist: GetRates, WhichRate, and Compute. The GetRates module gets the three rates as input. You may assume that only valid inputs will be provided. Assume that these rates will be integers. The WhichRate module returns the appropriate interest rate based on the term (years) of the GIC and Compute returns the final GIC value given a rate and the number of years. For N years and a rate of r%, the final value is
The code in gicrates.t reads as follows:
loop var rate1,rate2,rate3,rate : int var years : int var finalvalue : real GetRates(rate1,rate2,rate3) exit when rate1 = 0 loop put "Years? " .. get years exit when years = 0 rate := WhichRate(rate1,rate2,rate3,years) finalvalue := Compute(rate,years) put "After ",years," years you will get ", finalvalue:9:2, " dollars." end loop end loop
You may include the code of gicrates.t either by copying from the file /usr/copy/aps105/gicrates.t
into your file ``part2.t'' or by simply having the statement include "/usr/copy/aps105/gicrates.t"
after the declaration of your modules.
The modules you write may not use any global variables and they are not to output anything. You may not change the code you import from gicrates.t in any way.