Advertisement
nikolayneykov

Untitled

Apr 16th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         decimal budget = decimal.Parse(Console.ReadLine());
  8.         decimal pricePer1KgFlour = decimal.Parse(Console.ReadLine());
  9.         decimal priceForPackOfEggs = pricePer1KgFlour * 0.75m;
  10.         decimal priceFor1lMilk = pricePer1KgFlour * 1.25m * 0.25m;
  11.         decimal priceForCozonac = pricePer1KgFlour + priceFor1lMilk + priceForPackOfEggs;
  12.         int eggs = 0;
  13.         int cozonacs = 1;
  14.         while (budget >= priceForCozonac)
  15.         {
  16.             eggs += 3;
  17.             if (cozonacs % 3 == 0)
  18.             {
  19.                 eggs -= cozonacs - 2;
  20.             }
  21.             budget -= priceForCozonac;
  22.             cozonacs++;
  23.         }
  24.  
  25.         Console.WriteLine($"You made {cozonacs - 1} cozonacs! Now you have {eggs} eggs and {budget:F2}BGN left.");
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement