nikolayneykov

Untitled

Oct 15th, 2018
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.52 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace cleverLily
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             int ageLily = int.Parse(Console.ReadLine());
  15.             double wash = double.Parse(Console.ReadLine());
  16.             double toyPrice = double.Parse(Console.ReadLine());
  17.             double money = 0;
  18.  
  19.             double moneyMax = 0;
  20.  
  21.             int brotherTake = 0;
  22.             int numToy = 0;
  23.  
  24.             for (int itoy = 1; itoy <= ageLily; itoy++)
  25.             {
  26.                 if (itoy % 2 == 1)
  27.                 {
  28.                     numToy++;
  29.                 }
  30.             }
  31.             double allToyPrice = toyPrice * numToy;
  32.  
  33.  
  34.             for (int imoney = 1; imoney <= ageLily; imoney++)
  35.             {
  36.  
  37.                 if (imoney % 2 == 0)
  38.                 {
  39.                     money += 10;
  40.                     moneyMax += money;
  41.                     brotherTake++;
  42.  
  43.                 }
  44.  
  45.             }
  46.  
  47.             double allMoney = allToyPrice + moneyMax - brotherTake;
  48.             //Console.WriteLine(moneyMax);
  49.             //Console.WriteLine(allToyPrice);
  50.             //Console.WriteLine(allMoney);
  51.  
  52.             if (wash <= allMoney)
  53.             {
  54.                 Console.WriteLine($"Yes! {(allMoney - wash):F2}");
  55.             }
  56.             else
  57.             {
  58.                 Console.WriteLine($"No! {(wash - allMoney):F2}");
  59.             }
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment