Advertisement
Guest User

RENT

a guest
Dec 15th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _01._Rent
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int months = int.Parse(Console.ReadLine());
  10.             int percentComission = int.Parse(Console.ReadLine());
  11.             double priceRent = double.Parse(Console.ReadLine());
  12.  
  13.             double firstPeriod = 0;
  14.             double secondPeriod = 0;
  15.  
  16.             if (months%2==0)
  17.             {
  18.                 firstPeriod = months / 2;
  19.                 secondPeriod = months / 2;
  20.  
  21.  
  22.  
  23.             }
  24.             else
  25.             {
  26.                 firstPeriod = (months - 1) / 2;
  27.                 secondPeriod = firstPeriod + 1;
  28.             }
  29.            
  30.            
  31.             double rentFP = firstPeriod * priceRent;
  32.             double rentSP = secondPeriod * priceRent;
  33.            
  34.            
  35.              double rentSPSale = priceRent - (priceRent * 0.2);
  36.             double totalSP = rentSPSale * secondPeriod;
  37.            
  38.             double total = totalSP + rentFP;
  39.              double totalBroker = (total * percentComission)/100;
  40.            
  41.             double totaltotal = totalBroker + total;
  42.             Console.WriteLine($"Total: {totaltotal:F2}");
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement