Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace SmarLili
- {
- class Program
- {
- static void Main(string[] args)
- {
- int lilisAge = int.Parse(Console.ReadLine());
- double washingMachinePrice = double.Parse(Console.ReadLine());
- int priceOfSingleToy = int.Parse(Console.ReadLine());
- int moneyFromFather = 0;
- int countOfToys = 0;
- int moneyBrotherStole = 0;
- for (int currentYear = 1; currentYear <= lilisAge; currentYear++)
- {
- if (currentYear % 2 == 0)
- {
- moneyFromFather += (currentYear * 10) / 2;
- moneyBrotherStole++;
- }
- else
- {
- countOfToys++;
- }
- }
- int totalMoneySaved = (moneyFromFather - moneyBrotherStole) + (countOfToys * priceOfSingleToy);
- double moneyDiff = Math.Abs(totalMoneySaved - washingMachinePrice);
- if (totalMoneySaved >= washingMachinePrice)
- {
- Console.WriteLine($"Yes! {moneyDiff:f2}");
- }
- else
- {
- Console.WriteLine($"No! {moneyDiff:f2}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement