bacco

Лихва: Rate

Feb 6th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System;
  2.  
  3. namespace tESt
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             var sum = double.Parse(Console.ReadLine());
  10.             var months = int.Parse(Console.ReadLine());
  11.  
  12.             double interesSimple = sum;
  13.             double interesComplicated = sum;
  14.  
  15.             for (int i = 1; i <= months; i++)
  16.             {
  17.                 interesSimple = interesSimple + (sum * 0.03);
  18.  
  19.                 interesComplicated = interesComplicated + (interesComplicated * 0.027);
  20.             }
  21.  
  22.             Console.WriteLine($"Simple interest rate: {interesSimple:f2} lv.");
  23.             Console.WriteLine($"Complex interest rate: {interesComplicated:f2} lv.");
  24.  
  25.             if (interesSimple < interesComplicated)
  26.             {
  27.                 var diff = interesComplicated - interesSimple;
  28.                 Console.WriteLine($"Choose a complex interest rate. You will win {diff:f2} lv.");
  29.             }
  30.             else
  31.             {
  32.                 var diff =  interesSimple  - interesComplicated;
  33.                 Console.WriteLine($"Choose a simple interest rate. You will win {diff:f2} lv.");
  34.             }
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment