Advertisement
MARINA_GREBENAROVA

Clever_Lily

Oct 8th, 2021
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Clever_Lily
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int ageOfLilly = int.Parse(Console.ReadLine());
  10.             double priceOfLaundryM = double.Parse(Console.ReadLine());
  11.             int priceToy = int.Parse(Console.ReadLine());
  12.  
  13.             int toys = 0;
  14.             int money = 0;
  15.             int totalMoney = 0;
  16.  
  17.             for (int iterator = 1; iterator <= ageOfLilly; iterator++)
  18.             {
  19.                 money += 5;
  20.                 if (iterator % 2 == 0)
  21.                 {
  22.                     totalMoney += money - 1;
  23.                 }
  24.                 else
  25.                 {
  26.                     toys++;
  27.                 }
  28.  
  29.             }
  30.             totalMoney += toys * priceToy;
  31.  
  32.             if (totalMoney >= priceOfLaundryM)
  33.             {
  34.                 Console.WriteLine($"Yes! {totalMoney - priceOfLaundryM:F2}");
  35.             }
  36.             else
  37.             {
  38.                 Console.WriteLine($"No! {priceOfLaundryM - totalMoney:F2}");
  39.             }
  40.  
  41.         }
  42.     }
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement