Advertisement
bullit3189

Santa's Cookies TF-MidExam 10Jan19

Jan 26th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace _01Santa_sCookies
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int batches = int.Parse(Console.ReadLine());
  12.  
  13.  
  14. int totalBoxes = 0;
  15.  
  16. for (int i = 0; i < batches; i++)
  17. {
  18. int flourInGr = int.Parse(Console.ReadLine());
  19. int sugarInGr = int.Parse(Console.ReadLine());
  20. int cocoaInGr = int.Parse(Console.ReadLine());
  21.  
  22. int flourCaps = flourInGr / 140;
  23. int sugarSpoons = sugarInGr / 20;
  24. int cocoaSpoons = cocoaInGr / 10;
  25.  
  26. if (flourCaps<=0 || sugarSpoons<=0 || cocoaSpoons<=0)
  27. {
  28. Console.WriteLine("Ingredients are not enough for a box of cookies.");
  29. continue;
  30. }
  31.  
  32. double cocoaSpoonsCalculated = cocoaSpoons / 25.0;
  33. double sugarSpoonsCalculated = sugarSpoons / 25.0;
  34. double flourSpoonsCalculated = flourCaps / 25.0;
  35. double firstMin = Math.Min(flourSpoonsCalculated, sugarSpoonsCalculated);
  36. double finalMin = Math.Min(firstMin, cocoaSpoonsCalculated);
  37.  
  38. double cookiesPerBake =Math.Floor(170 * finalMin);
  39.  
  40. int boxesOfCookiesPerBake =(int) cookiesPerBake / 5;
  41.  
  42. Console.WriteLine($"Boxes of cookies: {boxesOfCookiesPerBake}");
  43.  
  44. totalBoxes += boxesOfCookiesPerBake;
  45. }
  46.  
  47. Console.WriteLine($"Total boxes: {totalBoxes}");
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement