Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _02.Problem_BeerStock
- {
- class BeerStock
- {
- static void Main(string[] args)
- {
- uint reservedBeers = uint.Parse(Console.ReadLine());
- string inputData = Console.ReadLine();
- uint allBeers = 0;
- while (inputData != "Exam Over")
- {
- string[] inputDataSplit = inputData.Split(' ');
- uint numBeers = uint.Parse(inputDataSplit[0]);
- if (inputDataSplit[1] == "beers")
- {
- allBeers += numBeers;
- }
- else if (inputDataSplit[1] == "cases")
- {
- uint calcBeersInCases = numBeers * 24;
- allBeers += calcBeersInCases;
- }
- else if (inputDataSplit[1] == "sixpacks")
- {
- uint calcBeersInSixpacks = numBeers * 6;
- allBeers += calcBeersInSixpacks;
- }
- inputData = Console.ReadLine();
- }
- if (allBeers >= 100)
- {
- allBeers = allBeers - (allBeers / 100);
- }
- if (allBeers >= reservedBeers)
- {
- uint beersLeft = allBeers - reservedBeers;
- uint leftCases = beersLeft / 24;
- uint beersLeftFromCases = beersLeft - (leftCases * 24);
- uint leftSixpacks = beersLeftFromCases / 6;
- uint leftBeers = beersLeftFromCases - (leftSixpacks * 6);
- Console.WriteLine("Cheers! Beer left: {0} cases, {1} sixpacks and {2} beers.", leftCases, leftSixpacks, leftBeers);
- }
- else
- {
- uint notEnought = reservedBeers - allBeers;
- uint needCases = notEnought / 24;
- uint beersLeftFromCases = notEnought - (needCases * 24);
- uint needSixpacs = beersLeftFromCases / 6;
- uint needBeer = beersLeftFromCases - (needSixpacs * 6);
- Console.WriteLine("Not enough beer. Beer needed: {0} cases, {1} sixpacks and {2} beers.", needCases, needSixpacs, needBeer);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement