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

hide comments
ajayc1007: 2018-06-15 15:15:03

Carefully calculate interest between each compound interest using PEN AND PAPER and detect a pattern !

Shashank Singh: 2015-01-12 11:49:26

Please tell mistake in my program

-----

Please see the Notes below:
>1. Don't post any source code here.
>3. For more discussion (hints, ideas, solutions) please visit our forum.

Last edit: 2015-01-12 14:22:25
Shashank Singh: 2015-01-12 11:47:26

my output is same as given but still getting wrong answer????? All the manupulations are correct...

Rishav Goyal: 2014-08-04 06:24:45

BORING ....

suryasis: 2014-03-18 22:04:09

% is just nt visible............wtf

ABHISHEK004: 2013-12-28 16:09:51

simple.. :)
just take care of that interest<$0.01 will not be added to principal

John Stephanus Peter: 2013-07-17 14:53:42

AC :)

Last edit: 2013-07-20 06:48:54
Himanshu: 2013-06-22 06:59:19

easy one :)
AC in one go.

mridul: 2013-05-21 16:45:17

i am getting time excceeded

Atul Kumar Verma: 2012-12-29 06:39:47

i am getting wrong answer. my output matches sample output.did i miss anything...plzz help..


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