Advertisement
miroslavpetrov96

Clever Lily PB C#

Aug 26th, 2020
959
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp2
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             var old = int.Parse(Console.ReadLine());
  10.             var priceForPeralnq = double.Parse(Console.ReadLine());
  11.             var priceForToy = double.Parse(Console.ReadLine());
  12.  
  13.             double toy = 0;
  14.             double savedMoneyFromBirthDay = 0.0;
  15.  
  16.             double totalMoney;
  17.             double secondMoney=0;
  18.             double counter = 0;
  19.             double priceFromToy = 0;
  20.            
  21.             for (int i = 1; i <= old; i++)
  22.             {
  23.                 if (i % 2 == 0)
  24.                 {
  25.                     savedMoneyFromBirthDay = savedMoneyFromBirthDay + 10;
  26.                     secondMoney = secondMoney + savedMoneyFromBirthDay;
  27.                     counter++;
  28.                 }
  29.                 else
  30.                     toy++;
  31.  
  32.             }
  33.             priceFromToy = toy * priceForToy;
  34.  
  35.             totalMoney = secondMoney + priceFromToy - counter;
  36.  
  37.            if(totalMoney > priceForPeralnq)
  38.             {
  39.                 Console.WriteLine("Yes! {0:f2}",Math.Abs(totalMoney-priceForPeralnq));
  40.             }
  41.            else
  42.                 Console.WriteLine("No! {0:F2}", Math.Abs(priceForPeralnq-totalMoney));
  43.         }
  44.     }
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement