Advertisement
Guest User

Easter Cozonacs

a guest
May 19th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Easter_Cozonacs
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. double budget = double.Parse(Console.ReadLine());
  10. double priceOfFloor = double.Parse(Console.ReadLine());
  11. double priceForEggs = 0.75 * priceOfFloor;
  12. double priceForMilk = 1.25 * priceOfFloor;
  13. double newBudget = budget;
  14. int numberOfCozonacsForCalculation = 0;
  15. int numberOfEggs = 0;
  16. int numberOfCozonacs = 0;
  17.  
  18. double priceForOneCozonacs = priceForEggs + priceOfFloor + 0.25 * priceForMilk;
  19.  
  20. while (priceForOneCozonacs < newBudget)
  21. {
  22. newBudget -= priceForOneCozonacs;
  23. numberOfCozonacsForCalculation++;
  24. numberOfEggs += 3;
  25. numberOfCozonacs++;
  26. if (numberOfCozonacsForCalculation == 3)
  27. {
  28. numberOfEggs -= numberOfCozonacs - 2;
  29. numberOfCozonacsForCalculation = 0;
  30. }
  31. }
  32. if (priceForOneCozonacs > newBudget)
  33. {
  34. Console.WriteLine($"You made {numberOfCozonacs} cozonacs! Now you have {numberOfEggs} eggs and {newBudget:f2}BGN left.");
  35. }
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement