Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Loops
- {
- class Program
- {
- static void Main(string[] args)
- {
- int age = int.Parse(Console.ReadLine());
- double washingMachine = double.Parse(Console.ReadLine());
- double toyPrice = double.Parse(Console.ReadLine());
- double moneyFromBirthdays = 0;
- double moneyGift = 10;
- int numOfToys = 0;
- for (int birthday = 1; birthday <= age; birthday++)
- {
- if(birthday % 2 == 0)
- {
- moneyFromBirthdays += moneyGift;
- moneyGift += 10;
- moneyFromBirthdays--;
- }
- else
- {
- numOfToys++;
- }
- double totalMoneyFromToys = numOfToys * toyPrice;
- double totalMoney = totalMoneyFromToys + moneyFromBirthdays;
- if(washingMachine <= totalMoney)
- {
- Console.WriteLine($"Yes! {totalMoney - washingMachine:F2}");
- }
- else
- {
- Console.WriteLine($"No! {washingMachine - totalMoney:F2}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement