Anzzhhela98

ff

Jun 11th, 2020
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Loops1100
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             //1.Read input
  10.             int age = int.Parse(Console.ReadLine());
  11.             double washPrice = double.Parse(Console.ReadLine());
  12.             double priceToys = int.Parse(Console.ReadLine());
  13.             double moneyFromBdays = 0;
  14.             double moneyGift = 10;
  15.             double numToys = 0;
  16.             //2.Loop throuhg the bdays
  17.            
  18.             for (int birthday = 1; birthday <= age; birthday++)
  19.             {
  20.                 //3.Check if the bday is even or odd
  21.                 if (birthday %2==0)
  22.                 {
  23.                     moneyFromBdays += moneyGift;
  24.                     moneyGift += 10;
  25.                     moneyFromBdays --;
  26.                 }
  27.                 else
  28.                 {
  29.                     numToys++;
  30.                 }
  31.             }
  32.             double totalMoneyFromToys = numToys * priceToys;
  33.             double totalMoney = totalMoneyFromToys + moneyFromBdays;
  34.             if (totalMoney >= washPrice)
  35.             {
  36.                 Console.WriteLine($"Yes! {totalMoney-washPrice:f2}");
  37.             }
  38.             else
  39.             {
  40.                 Console.WriteLine($"No! {washPrice-totalMoney:f2}");
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment