Skip to content

Instantly share code, notes, and snippets.

@EBojilova
Created April 26, 2015 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EBojilova/a6ab701a3d0125a23581 to your computer and use it in GitHub Desktop.
Save EBojilova/a6ab701a3d0125a23581 to your computer and use it in GitHub Desktop.
01.Compaund Interest
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