Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace For_Cycle
- {
- class Program
- {
- static void Main(string[] args)
- {
- int age = int.Parse(Console.ReadLine());
- double priceOfWashingMachine = double.Parse(Console.ReadLine());
- double priceofOneToy = double.Parse(Console.ReadLine());
- int toysCounter = 0;
- double moneyHolder = 0;
- int stolenMoney = 0;
- double moneyPresent = 0;
- for (int currentYear = 1; currentYear <= age; currentYear++)
- {
- if (currentYear % 2 != 0)
- {
- toysCounter++;
- }
- else
- {
- stolenMoney++;
- moneyHolder = moneyPresent;
- moneyPresent += 10;
- }
- }
- double moneyFromToys = toysCounter * priceofOneToy;
- double finalResult = (moneyHolder + moneyFromToys) - stolenMoney;
- if (finalResult >= priceOfWashingMachine)
- {
- Console.WriteLine($"Yes! ({(finalResult - priceOfWashingMachine):f2})");
- }
- else
- {
- Console.WriteLine($"No! {(priceOfWashingMachine - finalResult):f2}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment