Advertisement
bokoto83

Dishwasher

Jul 5th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Dishwasher
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int bottles = int.Parse(Console.ReadLine());
  14.             int quantity = bottles * 750;
  15.             int counter = 0;
  16.             int dishes = 0;
  17.             int pots = 0;
  18.  
  19.             while (quantity >= 0)
  20.             {
  21.                 counter++;
  22.                 string command = Console.ReadLine();
  23.                 if (command == "End")
  24.                 {
  25.                     Console.WriteLine("Detergent was enough!");
  26.                     Console.WriteLine($"{dishes} dishes and {pots} pots were washed.");
  27.                     Console.WriteLine($"Leftover detergent {quantity} ml.");
  28.                     break;
  29.                 }
  30.                 if (counter == 3)
  31.                 {
  32.                     pots = pots + int.Parse(command);
  33.                     quantity -= 15 * int.Parse(command);
  34.                     counter = 0;
  35.                 }
  36.                 else
  37.                 {
  38.                     dishes = dishes + int.Parse(command);
  39.                     quantity -= 5 * int.Parse(command);
  40.                 }    
  41.             }
  42.             if (quantity < 0)
  43.             {
  44.                 quantity = Math.Abs(quantity);
  45.                 Console.WriteLine($"Not enough detergent, {quantity} ml. more necessary!");
  46.                
  47.             }
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement