nikolayneykov

Untitled

Oct 15th, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System;
  2.  
  3. class CleverLily
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int lilyAge = int.Parse(Console.ReadLine());
  8.         double washmachinePrice = double.Parse(Console.ReadLine());
  9.         double toyPrice = double.Parse(Console.ReadLine());
  10.         double moneyGift = 10;
  11.         double totalSavings = 0;
  12.         for (int i = 1; i <= lilyAge; i++)
  13.         {
  14.             if (i % 2 == 1)
  15.             {
  16.                 totalSavings += toyPrice;
  17.             }
  18.             else
  19.             {
  20.                 totalSavings += moneyGift - 1;
  21.                 moneyGift += 10;
  22.             }
  23.         }
  24.         Console.WriteLine(totalSavings >= washmachinePrice ?
  25.             $"Yes! {totalSavings - washmachinePrice:F2}" :
  26.             $"No! {washmachinePrice - totalSavings:F2}");
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment