Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Kiso-blg
Last active March 13, 2016 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kiso-blg/5f622d2a6148ba6874fc to your computer and use it in GitHub Desktop.
Save Kiso-blg/5f622d2a6148ba6874fc to your computer and use it in GitHub Desktop.
C# Basics December 2014 Lab
using System;
namespace _01.Beers
{
class Beers
{
static void Main(string[] args)
{
int numberOfStacks = 0;
int numberOfBotles = 0;
string purchase = Console.ReadLine().ToLower();
while (purchase != "end")
{
string[] countAndMeasure = purchase.Split(' ');
int count = int.Parse(countAndMeasure[0]);
if (countAndMeasure[1] == "stacks")
{
numberOfStacks += count;
}
else
{
numberOfBotles += count;
}
purchase = Console.ReadLine().ToLower();
}
numberOfStacks += numberOfBotles / 20;
numberOfBotles %= 20;
Console.WriteLine("{0} stacks + {1} beers", numberOfStacks, numberOfBotles);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment