Advertisement
silvana1303

Easter Cozonacs

Jun 16th, 2020
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Threading;
  6.  
  7. namespace ConsoleApp1
  8. {
  9. class Exam
  10. {
  11. static void Main(string[] args)
  12. {
  13. double budget = double.Parse(Console.ReadLine());
  14. double priceFlour = double.Parse(Console.ReadLine());
  15.  
  16. double priceEggs = priceFlour * 0.75;
  17. double priceMilk = priceFlour * 1.25;
  18.  
  19. double eggBreadPrice = priceFlour + priceEggs + (priceMilk / 4);
  20.  
  21. int count = 0;
  22. int colouredEggs = 0;
  23.  
  24. while (budget > eggBreadPrice)
  25. {
  26. if (budget < eggBreadPrice)
  27. {
  28. break;
  29. }
  30.  
  31. budget -= eggBreadPrice;
  32.  
  33. count++;
  34. colouredEggs += 3;
  35.  
  36. if (count % 3 == 0)
  37. {
  38. colouredEggs -= count - 2;
  39. }
  40. }
  41.  
  42. Console.WriteLine($"You made {count} cozonacs! Now you have {colouredEggs} eggs and {budget:F2}BGN left.");
  43.  
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement