petarkobakov

Dishwasher

Feb 25th, 2020
683
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 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 bottlesDetergent = int.Parse(Console.ReadLine());
  10.  
  11. string command = Console.ReadLine();
  12. int consumptionDishes = 0;
  13. int consumptionPots = 0;
  14.  
  15. int dishes = 0;
  16. int pots = 0;
  17.  
  18. int detergentLitres = bottlesDetergent * 750;
  19. int loading = 0;
  20.  
  21. while (command != "End")
  22.  
  23. {
  24. int washedVessels = int.Parse(command);
  25. loading++;
  26.  
  27. if (loading %3 == 0)
  28. {
  29. pots += washedVessels;
  30. consumptionPots = washedVessels * 15;
  31. detergentLitres -= consumptionPots;
  32.  
  33. }
  34. else
  35. {
  36. dishes += washedVessels;
  37. consumptionDishes = washedVessels * 5;
  38. detergentLitres -= consumptionDishes;
  39. }
  40. if (detergentLitres < 0)
  41. {
  42. Console.WriteLine($"Not enough detergent, {Math.Abs(detergentLitres)} ml. more necessary!");
  43. return;
  44. }
  45.  
  46. command = Console.ReadLine();
  47.  
  48. }
  49.  
  50. if (detergentLitres >= 0)
  51. {
  52. Console.WriteLine("Detergent was enough!");
  53. Console.WriteLine($"{dishes} dishes and {pots} pots were washed.");
  54. Console.WriteLine($"Leftover detergent {detergentLitres} ml.");
  55. }
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment