Advertisement
simonradev

SmartLili

Jun 28th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 KB | None | 0 0
  1. using System;
  2.  
  3. namespace SmarLili
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int lilisAge = int.Parse(Console.ReadLine());
  10.             double washingMachinePrice = double.Parse(Console.ReadLine());
  11.             int priceOfSingleToy = int.Parse(Console.ReadLine());
  12.  
  13.             int moneyFromFather = 0;
  14.             int countOfToys = 0;
  15.             int moneyBrotherStole = 0;
  16.             for (int currentYear = 1; currentYear <= lilisAge; currentYear++)
  17.             {
  18.                 if (currentYear % 2 == 0)
  19.                 {
  20.                     moneyFromFather += (currentYear * 10) / 2;
  21.                     moneyBrotherStole++;
  22.                 }
  23.                 else
  24.                 {
  25.                     countOfToys++;
  26.                 }
  27.             }
  28.  
  29.             int totalMoneySaved = (moneyFromFather - moneyBrotherStole) + (countOfToys * priceOfSingleToy);
  30.  
  31.             double moneyDiff = Math.Abs(totalMoneySaved - washingMachinePrice);
  32.             if (totalMoneySaved >= washingMachinePrice)
  33.             {
  34.                 Console.WriteLine($"Yes! {moneyDiff:f2}");
  35.             }
  36.             else
  37.             {
  38.                 Console.WriteLine($"No! {moneyDiff:f2}");
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement