elena1234

EasterCozonacs

Oct 11th, 2020 (edited)
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System;
  2.  
  3. namespace EasterCozonacs
  4. {
  5.     class MainClass
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             double budget = double.Parse(Console.ReadLine());
  10.             double price1kgFlour = double.Parse(Console.ReadLine());
  11.             double price1packEggs = 0.75 * price1kgFlour;
  12.             double price1lMilk= price1kgFlour + (0.25 * price1kgFlour);
  13.             double priceMilkForOneCozunac = price1lMilk / 4;
  14.             double totalPriceForOneCozunac = price1kgFlour + price1packEggs + priceMilkForOneCozunac;
  15.             int countCozunacs = (int) Math.Floor(budget / totalPriceForOneCozunac);
  16.             int countColoredEggs = 0;
  17.             double moneyLeft = budget - (totalPriceForOneCozunac * countCozunacs);
  18.  
  19.             for (int i = 1; i <=countCozunacs; i++)
  20.             {
  21.                 countColoredEggs += 3;
  22.                 if (i % 3 == 0)
  23.                 {
  24.                     countColoredEggs -= i - 2;
  25.                 }
  26.             }
  27.  
  28.             Console.WriteLine($"You made {countCozunacs} cozonacs! Now you have {countColoredEggs} eggs and {moneyLeft:F2}BGN left.");
  29.           }
  30.          }
  31.        }
  32.  
Add Comment
Please, Sign In to add comment