Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Clever_Lilly
- {
- class Program
- {
- static void Main(string[] args)
- {
- int age = int.Parse(Console.ReadLine());
- double priceWashingMachine = double.Parse(Console.ReadLine());
- int priceForOneToy = int.Parse(Console.ReadLine());
- int toysCounter = 0;
- int savedMoney = 0;
- int stolenMoney = 0;
- int prevBirthday = 0;
- for (int currentBirthday = 1; currentBirthday <= age; currentBirthday++)
- {
- if (currentBirthday % 2 != 0 )
- {
- toysCounter++;
- }
- else
- {
- savedMoney += 10;
- prevBirthday += savedMoney;
- stolenMoney++;
- }
- }
- int totalMoneyFromToys = priceForOneToy * toysCounter;
- int totalSavedMoney = (prevBirthday + totalMoneyFromToys) - stolenMoney;
- if (priceWashingMachine <= totalSavedMoney)
- {
- Console.WriteLine($"Yes! {Math.Abs(priceWashingMachine - totalSavedMoney):f2}");
- }
- else
- {
- Console.WriteLine($"No! {Math.Abs(totalSavedMoney - priceWashingMachine):f2}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement