Advertisement
Guest User

Untitled

a guest
Apr 30th, 2020
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Dishwasher
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int bottlesOfCleaner = int.Parse(Console.ReadLine());
  10. // 1 bottle holds 750ml, one plate needs 5, one pot needs 15, if i % 3 == 0 pots, else pans
  11. int amountOfLiquid = bottlesOfCleaner * 750;
  12. int liquidNeeded = 0;
  13. int numberOfPlates = 0;
  14. int numberOfPots = 0;
  15.  
  16. int counter = 1;
  17.  
  18. while (true)
  19. {
  20.  
  21.  
  22. string input = Console.ReadLine();
  23. if (input == "End")
  24. {
  25. break;
  26. }
  27.  
  28.  
  29. if (counter % 3 == 0)
  30. {
  31. int pots = int.Parse(input);
  32. numberOfPots += pots;
  33.  
  34. liquidNeeded = pots * 15;
  35. amountOfLiquid -= liquidNeeded;
  36. }
  37. else
  38. {
  39. int dishes = int.Parse(input);
  40. numberOfPlates += dishes;
  41.  
  42. liquidNeeded = dishes * 5;
  43. amountOfLiquid -= liquidNeeded;
  44. }
  45.  
  46.  
  47. if (amountOfLiquid < liquidNeeded)
  48. {
  49. break;
  50. }
  51. counter++;
  52.  
  53. }
  54. if (amountOfLiquid > liquidNeeded)
  55. {
  56. Console.WriteLine("Detergent was enough!");
  57. Console.WriteLine($"{numberOfPlates} dishes and {numberOfPots} pots were washed.");
  58. Console.WriteLine($"Leftover detergent {amountOfLiquid} ml.");
  59.  
  60. }
  61. else
  62. {
  63. Console.WriteLine($"Not enough detergent, {amountOfLiquid} ml. more necessary!");
  64. }
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement