Created
April 26, 2015 21:32
-
-
Save EBojilova/a6ab701a3d0125a23581 to your computer and use it in GitHub Desktop.
01.Compaund Interest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class CompaundInterest | |
{ | |
static void Main(string[] args) | |
{ | |
decimal p = decimal.Parse(Console.ReadLine()); | |
int n = int.Parse(Console.ReadLine()); | |
decimal i = decimal.Parse(Console.ReadLine()); | |
decimal f = decimal.Parse(Console.ReadLine()); | |
decimal bankOffer = (1 + i); | |
for (int j = 1; j < n; j++) | |
{ | |
bankOffer *= (1 + i); | |
} | |
bankOffer *= p; | |
decimal friendOffer = p * (1+f); | |
if (friendOffer<=bankOffer) | |
{ | |
Console.WriteLine("{0:F2} {1}", friendOffer, "Friend"); | |
} | |
else | |
{ | |
Console.WriteLine("{0:F2} {1}", bankOffer, "Bank"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment