Advertisement
nikolayneykov

Untitled

Oct 17th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 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 ConsoleApp27
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int lilyAge = int.Parse(Console.ReadLine());
  14.             double washingMachinePrice = double.Parse(Console.ReadLine());
  15.             int toyPrice = int.Parse(Console.ReadLine());
  16.             double birthdayMoney = 10;
  17.             double sumOfMoney = 0;
  18.  
  19.             double amountOfToys = 0;
  20.  
  21.             for (int i = 1; i <= lilyAge; i++)
  22.             {
  23.                 if (i % 2 == 0)
  24.                 {
  25.                     sumOfMoney = sumOfMoney + birthdayMoney -1;
  26.                     birthdayMoney += 10;
  27.                 }
  28.                 if (i % 2 != 0)
  29.                 {
  30.                     amountOfToys += 1;
  31.                 }
  32.             }
  33.  
  34.             double totalMoney = sumOfMoney + (amountOfToys * toyPrice);
  35.  
  36.             if (totalMoney >= washingMachinePrice)
  37.             {
  38.                 double moneyLeft = totalMoney - washingMachinePrice;
  39.                 Console.WriteLine($"Yes! {moneyLeft:F2}");
  40.             }
  41.             else if (totalMoney < washingMachinePrice)
  42.             {
  43.                 double moneyShort = washingMachinePrice - totalMoney;
  44.                 Console.WriteLine($"No! {moneyShort:F2}");
  45.             }
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement