Advertisement
Guest User

04. Smart Lily

a guest
Mar 11th, 2018
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _02.Умната_Лили
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             var age = int.Parse(Console.ReadLine());
  10.             var washingPrice = double.Parse(Console.ReadLine());
  11.             var toyPrice = double.Parse(Console.ReadLine());
  12.             double moneyForBD = 10.0;
  13.             double toyCount = 0.0;
  14.             double savedMoney = 0.0;
  15.             double totalMoney = 0.0;
  16.  
  17.             for (int currAge = 1; currAge <= age; currAge++)
  18.             {
  19.                 if (currAge % 2 == 0)
  20.                 {
  21.                     savedMoney += moneyForBD - 1;
  22.                     moneyForBD += 10;
  23.                 }
  24.                 else toyCount++;
  25.             }
  26.  
  27.             totalMoney = savedMoney + (toyPrice * toyCount);
  28.  
  29.             if (totalMoney >= washingPrice) Console.WriteLine("Yes! {0:f2}", totalMoney - washingPrice);
  30.             else Console.WriteLine("No! {0:f2}", washingPrice - totalMoney);
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement