Last active
March 13, 2016 09:11
-
-
Save Kiso-blg/5f622d2a6148ba6874fc to your computer and use it in GitHub Desktop.
C# Basics December 2014 Lab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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