Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Dishwasher
- {
- class Program
- {
- static void Main(string[] args)
- {
- int bottlesOfCleaner = int.Parse(Console.ReadLine());
- // 1 bottle holds 750ml, one plate needs 5, one pot needs 15, if i % 3 == 0 pots, else pans
- int amountOfLiquid = bottlesOfCleaner * 750;
- int liquidNeeded = 0;
- int numberOfPlates = 0;
- int numberOfPots = 0;
- int counter = 1;
- while (true)
- {
- string input = Console.ReadLine();
- if (input == "End")
- {
- break;
- }
- if (counter % 3 == 0)
- {
- int pots = int.Parse(input);
- numberOfPots += pots;
- liquidNeeded = pots * 15;
- amountOfLiquid -= liquidNeeded;
- }
- else
- {
- int dishes = int.Parse(input);
- numberOfPlates += dishes;
- liquidNeeded = dishes * 5;
- amountOfLiquid -= liquidNeeded;
- }
- if (amountOfLiquid < liquidNeeded)
- {
- break;
- }
- counter++;
- }
- if (amountOfLiquid > liquidNeeded)
- {
- Console.WriteLine("Detergent was enough!");
- Console.WriteLine($"{numberOfPlates} dishes and {numberOfPots} pots were washed.");
- Console.WriteLine($"Leftover detergent {amountOfLiquid} ml.");
- }
- else
- {
- Console.WriteLine($"Not enough detergent, {amountOfLiquid} ml. more necessary!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement