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