fbinnzhivko

01.00 Compound interest

Mar 13th, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2.  
  3. public class CompoundInterest
  4. {
  5.     public static void Main()
  6.     {
  7.         double priceOfTv = double.Parse(Console.ReadLine());
  8.         int bankLoanTerm = int.Parse(Console.ReadLine());
  9.         double bankInterestRate = double.Parse(Console.ReadLine());
  10.         double friendInterest = double.Parse(Console.ReadLine());
  11.  
  12.         double bankPrice = Math.Pow((1 + bankInterestRate), bankLoanTerm) * priceOfTv;
  13.         double friendPrice = (1 + friendInterest) * priceOfTv;
  14.  
  15.         double bestPrice = Math.Min(bankPrice, friendPrice);
  16.         string bestLender = bankPrice < friendPrice ? "Bank" : "Friend";
  17.  
  18.         Console.WriteLine("{0:F2} {1}", bestPrice, bestLender);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment