bullit3189

Baking Masterclass TF MidExam 27Oct18

Jan 26th, 2019
73
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 _01BakingMasterclass
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. double budget = double.Parse(Console.ReadLine());
  10. int students = int.Parse(Console.ReadLine());
  11. double priceFlourPkg = double.Parse(Console.ReadLine());
  12. double pricePerEgg = double.Parse(Console.ReadLine());
  13. double pricePerApron = double.Parse(Console.ReadLine());
  14.  
  15. double priceEggsPerStudent = 10 * pricePerEgg;
  16.  
  17. int flourPkgs = students;
  18. int freeFlourPkgs = 0;
  19.  
  20. for (int i = 1; i <= flourPkgs; i++)
  21. {
  22. if (i % 5 == 0)
  23. {
  24. freeFlourPkgs++;
  25. }
  26. }
  27. int totalFlourPkgs = flourPkgs - freeFlourPkgs;
  28. double aprons = Math.Ceiling(1.2 * students);
  29.  
  30. double totalPrice = (totalFlourPkgs * priceFlourPkg) + (priceEggsPerStudent * students) + (aprons * pricePerApron);
  31.  
  32. if (totalPrice <= budget)
  33. {
  34. Console.WriteLine("Items purchased for {0:f2}$.", totalPrice);
  35. }
  36. else
  37. {
  38. Console.WriteLine("{0:f2}$ more needed.", totalPrice - budget);
  39. }
  40. }
  41. }
  42. }
Add Comment
Please, Sign In to add comment