Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace zadachi
- {
- class Program
- {
- static void Main(string[] args)
- {
- int age = int.Parse(Console.ReadLine());
- double washingmashine = double.Parse(Console.ReadLine());
- double toyPrice = double.Parse(Console.ReadLine());
- double savedMoney = 0;
- int toyCount = 0;
- double moneyByToys = 0;
- int moneyByBrother = 0;
- for (int i = 1; i <= age; i++)
- {
- if (i % 2 == 0)
- {
- savedMoney += i * 5;
- moneyByBrother++;
- }
- else
- {
- toyCount++;
- moneyByToys = toyCount * toyPrice;
- }
- }
- double totalMoney = (savedMoney - moneyByBrother) + moneyByToys;
- if (totalMoney >= washingmashine)
- {
- Console.WriteLine($"Yes! {totalMoney - washingmashine:f2}");
- }
- else
- {
- Console.WriteLine($"No! {washingmashine - totalMoney:f2}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement