MKMONEY - Making Money

A trick sometimes used by parents to teach their children the value of money is to give then a penny – just a penny! – and the promise that for each day they don’t spend it, the parent will double it. All students of computing know that long before a month has elapsed without spending a cent, the parents will not likely be able to make good on their promise.

100-percent compound daily interest on an investment is, of course, unattainable in normal financial dealings, but we are all continually reminded of the power of compound interest, even with the relatively low interest rates available today.

But exactly how much money can be made with compound interest? Assume, for example, an initial investment of $100.00 (US or Canadian ☺), an annual interest rate of 6.00 percent, and that interest is compounded monthly. That is, the interest earned during the preceding month is added to the principal at the end of the month. (For our purposes, we’ll assume a month is exactly 1/12th of a year.)

At the end of the first month, the money will have earned 0.5 percent interest (1/12th of 6.00 percent), or $0.50. This is added to the $100.00 invested, so that during the next month, interest is paid on $100.50. During the next month another 0.5 percent interest is earned, which is exactly $0.5025. We will assume that the bank, being conservative, will not pay any interest less than $0.01, so our investment is credited with an additional $0.50 at the end of the second month, for a whopping total of $101.00. Continuing in the same manner, at the end of 12 months our investment will total $106.12, $0.12 more than simple 6.00 percent interest for a year with no compounding.

Given an amount P to be invested for a year with I percent interest, compounded C times during the year at equal intervals, what is total return on the investment?

Input

There will be multiple cases to consider. The input for each case is a single line containing the initial investment amount, P, given in dollars and cents (but no fractional cents, and no larger than $100,000.00), the annual interest rate (I) given as a real number with two fractional digits representing a percentage, greater than zero but less than 100, and the number of compounding intervals per year (C), an integer between 1 and 365. The last case will be followed by a line containing “0.00 0.00 0”.

Output

For each input case, display the case number (1, 2, …), the initial investment (P), the annual interest rate (I), the number of compounding intervals per year(C), and the value of the investment at the end of a year. Your output should follow the format shown in the examples below.

Example

Input:
100.00 6.00 1
100.00 6.00 12
1000.00 6.00 12
0.00 0.00 0

Output:
Case 1. $100.00 at 6.00% APR compounded 1 times yields $106.00
Case 2. $100.00 at 6.00% APR compounded 12 times yields $106.12
Case 3. $1000.00 at 6.00% APR compounded 12 times yields $1061.63

Added by:Camilo Andrés Varela León
Date:2007-10-07
Time limit:0.100s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:North Central North America Regional Programming Contest - 2003

hide comments
2012-12-29 06:39:47 Atul Kumar Verma
i am getting wrong answer. my output matches sample output.did i miss anything...plzz help..
2012-01-24 15:22:46 Kim Fts
O.K. I understand now.

Last edit: 2012-01-30 16:32:33
2011-10-13 10:53:50 sri
whats the problem? the answer is rite, still wa?
2011-10-13 10:22:59 sri
hey its showing wa again again..
plz tel me where i am wrong
2010-08-10 19:03:01 hendrik
I have verified the update. Thanks a lot.
2010-08-09 19:27:32 kuszi
@hendrik Thank you, corrected.
2010-01-06 19:17:55 hendrik
The test data contain a test case:
1.00 100.0 1
which does not comply with the Input specification. Depending on how you read the input it matters or it doesnt. I think the test data should be updated.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.