petaryankov00

CleverLili

Oct 27th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. using System;
  2.  
  3. namespace SmartLili
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int age = int.Parse(Console.ReadLine());
  10.             double priceWashmachine = double.Parse(Console.ReadLine());
  11.             int toyPrice = int.Parse(Console.ReadLine());
  12.  
  13.             int sumMoney = 0;
  14.             int countToys = 0;
  15.             int oldValue = 0;
  16.            int  stolenLeva = 0;
  17.  
  18.             for (int currentBirthday = 1; currentBirthday <= age; currentBirthday++)
  19.             {
  20.                 if (currentBirthday % 2 == 0)
  21.                 {                  
  22.                     oldValue +=10;
  23.                     sumMoney = sumMoney + oldValue;
  24.                     stolenLeva++;
  25.                 }
  26.                 else
  27.                 {
  28.                     countToys++;
  29.                 }
  30.             }
  31.             double sumToys = countToys * toyPrice;
  32.             sumMoney = sumMoney - stolenLeva;
  33.             double finalMoney = sumMoney + sumToys;
  34.  
  35.             if (finalMoney >= priceWashmachine)
  36.             {
  37.                 Console.WriteLine($"Yes! {(finalMoney - priceWashmachine):F2}");
  38.             }
  39.             else
  40.             {
  41.                 Console.WriteLine($"No! {(priceWashmachine - finalMoney):F2}");
  42.             }
  43.            
  44.  
  45.  
  46.  
  47.            
  48.  
  49.         }
  50.     }
  51. }
  52.  
Add Comment
Please, Sign In to add comment