Advertisement
Daniel_007

12. Clever Lily

Oct 19th, 2019
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 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 age = int.Parse(Console.ReadLine());
  10.             double priceWashing = double.Parse(Console.ReadLine());
  11.             int priceToy = int.Parse(Console.ReadLine());
  12.             double money = 0;
  13.             int toys = 0;
  14.             double sum = 0;
  15.             for (int i = 1; i <= age; i++)
  16.             {
  17.                 if (i % 2 == 0)
  18.                 {
  19.                     money += 5 * i - 1;
  20.                 }
  21.                 else
  22.                 {
  23.                     toys++;
  24.                 }
  25.             }
  26.             sum = toys * priceToy + money;
  27.             if (priceWashing > sum)
  28.             {
  29.                 Console.WriteLine($"No! {priceWashing- sum:F2}");
  30.             }
  31.             else
  32.             {
  33.                 Console.WriteLine($"Yes! {sum - priceWashing:F2}");
  34.             }
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement