MiroslavKisov

Smart_Lily

Jul 26th, 2017
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Smart_Lily
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int age = int.Parse(Console.ReadLine());
  14.             double priceOfWashingMachine = double.Parse(Console.ReadLine());
  15.             double priceOfToys = double.Parse(Console.ReadLine());
  16.             int moneyStart = 10;
  17.             int moneySaved = 0;
  18.             int toys = 0;
  19.             int brother = 0;
  20.             double allMoney = 0.0d;
  21.             for(int i = 1; i <= age; i++)
  22.             {
  23.                 if(i%2==0&&i!=1)
  24.                 {
  25.                     moneySaved = moneySaved + moneyStart;
  26.                     moneyStart += 10;
  27.                     brother++;
  28.                 }
  29.                 else if(i%2!=0||i==1)
  30.                 {
  31.                     toys++;
  32.                 }
  33.             }
  34.             allMoney = toys * priceOfToys + moneySaved-brother;
  35.             if(allMoney>=priceOfWashingMachine)
  36.             {
  37.                 allMoney = allMoney - priceOfWashingMachine;
  38.                 Console.WriteLine($"Yes! {allMoney:f2}");
  39.             }
  40.             else
  41.             {
  42.                 allMoney = Math.Abs(allMoney - priceOfWashingMachine);
  43.                 Console.WriteLine($"No! {allMoney:f2}");
  44.             }
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment