Advertisement
Aliendreamer

water dispenser

Jul 2nd, 2018
851
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 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 Water_dispenser
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             int cupVolume = int.Parse(Console.ReadLine());
  15.             int counter = 0;          
  16.             int overallVolume = 0;
  17.             int volume = 0;
  18.            
  19.             string buttons;
  20.            
  21.             while ((buttons = Console.ReadLine())!=null && overallVolume<cupVolume)
  22.             {
  23.                            
  24.             switch(buttons)
  25.             {
  26.                 case "Easy":
  27.                    
  28.                     volume = 50;
  29.                     break;
  30.                case"Medium":                
  31.                      volume = 100;
  32.                 break;
  33.                case"Hard":
  34.                
  35.                  volume = 200;
  36.                 break;
  37.             }
  38.                 overallVolume += volume;
  39.  
  40.             counter++;
  41.          
  42.             }
  43.            
  44.                 if (overallVolume > cupVolume)
  45.                 {
  46.                    int spiltWater = overallVolume - cupVolume;
  47.                     Console.WriteLine($"{spiltWater}ml has been spilled.");
  48.                 }
  49.                 else
  50.                 {
  51.                 Console.WriteLine($"The dispenser has been tapped {counter} times.");
  52.                 }
  53.        }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement