Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Loops1100
- {
- class Program
- {
- static void Main(string[] args)
- {
- //1.Read input
- int age = int.Parse(Console.ReadLine());
- double washPrice = double.Parse(Console.ReadLine());
- double priceToys = int.Parse(Console.ReadLine());
- double moneyFromBdays = 0;
- double moneyGift = 10;
- double numToys = 0;
- //2.Loop throuhg the bdays
- for (int birthday = 1; birthday <= age; birthday++)
- {
- //3.Check if the bday is even or odd
- if (birthday %2==0)
- {
- moneyFromBdays += moneyGift;
- moneyGift += 10;
- moneyFromBdays --;
- }
- else
- {
- numToys++;
- }
- }
- double totalMoneyFromToys = numToys * priceToys;
- double totalMoney = totalMoneyFromToys + moneyFromBdays;
- if (totalMoney >= washPrice)
- {
- Console.WriteLine($"Yes! {totalMoney-washPrice:f2}");
- }
- else
- {
- Console.WriteLine($"No! {washPrice-totalMoney:f2}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment