Advertisement
Niicksana

Clever Lilly

Dec 8th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 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 Clever_Lilly
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // Exam - 24 April 2016
  14.             int age = int.Parse(Console.ReadLine());
  15.             double price = double.Parse(Console.ReadLine());
  16.             int priceToy = int.Parse(Console.ReadLine());
  17.  
  18.             int toys = 0;
  19.             int money = 0;
  20.             int yearMoney = 0;
  21.             int moneyCount = 0;
  22.  
  23.             for (int bday = 1; bday <= age; bday++)
  24.             {
  25.                 if (bday % 2 == 0)
  26.                 {
  27.                     moneyCount++;
  28.                     money += 10;
  29.                     yearMoney += money;
  30.                 }
  31.  
  32.                 else
  33.                 {
  34.                     toys++;
  35.                 }
  36.             }
  37.  
  38.             int totalPriceToys = toys * priceToy;
  39.             int totalMoney = yearMoney + totalPriceToys - moneyCount;
  40.             double difference = Math.Abs(totalMoney - price);
  41.  
  42.             if (totalMoney >= price)
  43.             {
  44.                 Console.WriteLine("Yes! {0:f2}", difference);
  45.             }
  46.  
  47.             else
  48.             {
  49.                 Console.WriteLine("No! {0:f2}", difference);
  50.             }
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement