Advertisement
tsvetelinapasheva

TsvetelinaPasheva/ForLoopLab/11.ClerverLily

Feb 2nd, 2021
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp17
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int age = int.Parse(Console.ReadLine());
  10.             double washingmachinePrice = double.Parse(Console.ReadLine());
  11.             double toyPrice = double.Parse(Console.ReadLine());
  12.             int birthdayMoney = 10;
  13.             double savedMoney = 0;
  14.             int toyCounter = 0;
  15.              
  16.             for (int i = 1; i <= age; i++)
  17.             {
  18.                 if (i % 2 == 0)
  19.                 {
  20.                     savedMoney += birthdayMoney;
  21.                     savedMoney--;
  22.                     birthdayMoney += 10;
  23.                 }
  24.                 else
  25.                 {
  26.                     toyCounter++;
  27.                 }
  28.             }
  29.             double moneyForToys = toyCounter * toyPrice;
  30.             savedMoney += moneyForToys;
  31.             if (savedMoney >= washingmachinePrice)
  32.             {
  33.                 Console.WriteLine($"Yes! {savedMoney - washingmachinePrice:f2}");
  34.             }
  35.             else
  36.             {
  37.                 Console.WriteLine($"No! {washingmachinePrice - savedMoney:f2}");
  38.             }
  39.         }
  40.     }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement