Advertisement
LOH_DIMI3

01.Dishwasher

Oct 9th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. using System;
  2.  
  3. namespace asd
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int bottlesOfDetergent = int.Parse(Console.ReadLine());
  10.             bottlesOfDetergent *= 750;
  11.             // 1 dish requere 5 mils of detergent
  12.             // 1 pot requere 15 mils of detergent
  13.             // every third load is only pots the other time is only dishes
  14.  
  15.             string command = Console.ReadLine();
  16.             int count = 0;
  17.             int mlFromDishes = 0;
  18.             int dish = 0;
  19.             int pot = 0;
  20.             while (command != "End")
  21.             {
  22.                 int dishes = int.Parse(command);
  23.                 count++;
  24.                 if (count == 3)
  25.                 {
  26.                     dishes *= 15;
  27.                     pot += int.Parse(command);
  28.                     count = 0;
  29.                 }
  30.                 else
  31.                 {
  32.                     dishes *= 5;
  33.                     dish += int.Parse(command);
  34.                 }
  35.                 mlFromDishes += dishes;
  36.                 if (mlFromDishes >= bottlesOfDetergent)
  37.                 {
  38.                     int necessaryDetergent = mlFromDishes - bottlesOfDetergent;
  39.                     Console.WriteLine($"Not enough detergent, {necessaryDetergent} ml. more necessary!");
  40.                     return;
  41.                 }
  42.                 command = Console.ReadLine();
  43.             }
  44.             int leftOverDetergent = bottlesOfDetergent - mlFromDishes;
  45.             Console.WriteLine($"Detergent was enough!");
  46.             Console.WriteLine($"{dish} dishes and {pot} pots were washed.");
  47.             Console.WriteLine($"Leftover detergent {leftOverDetergent} ml.");
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement