Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp27
- {
- class Program
- {
- static void Main(string[] args)
- {
- int lilyAge = int.Parse(Console.ReadLine());
- double washingMachinePrice = double.Parse(Console.ReadLine());
- int toyPrice = int.Parse(Console.ReadLine());
- double birthdayMoney = 10;
- double sumOfMoney = 0;
- double amountOfToys = 0;
- for (int i = 1; i <= lilyAge; i++)
- {
- if (i % 2 == 0)
- {
- sumOfMoney = sumOfMoney + birthdayMoney -1;
- birthdayMoney += 10;
- }
- if (i % 2 != 0)
- {
- amountOfToys += 1;
- }
- }
- double totalMoney = sumOfMoney + (amountOfToys * toyPrice);
- if (totalMoney >= washingMachinePrice)
- {
- double moneyLeft = totalMoney - washingMachinePrice;
- Console.WriteLine($"Yes! {moneyLeft:F2}");
- }
- else if (totalMoney < washingMachinePrice)
- {
- double moneyShort = washingMachinePrice - totalMoney;
- Console.WriteLine($"No! {moneyShort:F2}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement