fbinnzhivko

Умната Лили

May 13th, 2016
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main()
  5.     {
  6.         int lilyAge = int.Parse(Console.ReadLine());
  7.         double price = double.Parse(Console.ReadLine());
  8.         int priceToy = int.Parse(Console.ReadLine());
  9.  
  10.         int moneyForBirthDay = 10;
  11.         int total = 0;
  12.         int counter = 0;
  13.         int toy = 0;
  14.         int pariBrat = lilyAge / 2;
  15.  
  16.         for (int i = 1; i <= lilyAge; i++)
  17.         {
  18.             if (i % 2 == 0)
  19.             {
  20.                 moneyForBirthDay = i * 5;
  21.                 total = total + moneyForBirthDay;
  22.             }
  23.             else
  24.             {
  25.                 counter++;
  26.                 toy = counter * priceToy;
  27.             }
  28.         }
  29.         double totalSum = Math.Abs(total + toy - pariBrat);
  30.        
  31.         if (totalSum >= price)
  32.         {
  33.             Console.WriteLine("Yes! {0:F2}", totalSum);
  34.         }
  35.         else
  36.         {
  37.             Console.WriteLine("No! {0:F2}", totalSum);
  38.         }
  39.     }
  40. }
Add Comment
Please, Sign In to add comment