Advertisement
a_tifonoff

Nakov's beers1

Jan 27th, 2015
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 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 NakovBeer
  8. {
  9.     class NakovBeer
  10.     {
  11.         static void Main()
  12.         {
  13.             int quantity;
  14.             int beerCounter=0;
  15.             for (int loops = 1; loops < 999; loops++)
  16.             {
  17.  
  18.                 string inputData = Console.ReadLine();
  19.  
  20.                 if(inputData=="End")
  21.                     {
  22.                         break;
  23.                     }
  24.                 string[] data = inputData.Split(' ');
  25.             quantity = int.Parse(data[0]);
  26.                     if (quantity > 99 || quantity < 1)
  27.                     {
  28.                         Console.WriteLine("NOT CORECT Please try adain");
  29.                         quantity=0;
  30.                     }
  31.  
  32.                 string type = data[1];
  33.                 if(type=="stacks")
  34.                 {
  35.                    beerCounter +=quantity*20;
  36.                 }
  37.                 else
  38.                 {
  39.                     beerCounter += quantity;
  40.                 }
  41.            }
  42.             int stacks = beerCounter / 20;
  43.             int beers = beerCounter % 20;
  44.             Console.WriteLine("{0} stacks + {1} beers",stacks,beers);
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement