Advertisement
EmoRz

Smart Lilly

Jul 16th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. using System;
  2.  
  3. namespace SmartLily
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int age = int.Parse(Console.ReadLine());
  10.             double priceWashEngine = double.Parse(Console.ReadLine());
  11.             int priceToy = int.Parse(Console.ReadLine());
  12.  
  13.             var even = 0.0;
  14.             var evenR = 0.0;
  15.             var brother = 0;
  16.             var odd = 0.0;
  17.  
  18.             for (int i = 1; i <= age; i++)
  19.             {
  20.                 if (i%2==0)
  21.                 {
  22.                     brother++;
  23.                     even += 10;
  24.                     evenR += even;
  25.                 }
  26.                 else
  27.                 {
  28.                     odd++;
  29.                 }
  30.             }
  31.             var allSum = (priceToy*odd)+(evenR - brother);
  32.             var testForWE = allSum - priceWashEngine;
  33.             if (testForWE>=0)
  34.             {
  35.                 Console.Write("Yes! ");
  36.                 Console.WriteLine($"{testForWE:f2}");
  37.             }
  38.             else
  39.             {
  40.                 var middCalc = Math.Abs(testForWE);
  41.                 Console.Write("No! ");
  42.                 Console.WriteLine($"{middCalc:f2}");
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement