Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace BeerStock
- {
- class Program
- {
- static void Main(string[] args)
- {
- int neededBeers = int.Parse(Console.ReadLine());
- long deliveredBeers = 0;
- string command;
- while ((command = Console.ReadLine()) != "Exam Over")
- {
- var package = command.Split(' ');
- long amount = long.Parse(package[0]);
- string type = package[1];
- if (type == "sixpacks")
- {
- amount *= 6;
- }
- else if (type == "cases")
- {
- amount *= 24;
- }
- deliveredBeers += amount;
- }
- deliveredBeers -= deliveredBeers / 100;
- long diff = Math.Abs(neededBeers - deliveredBeers);
- long cases = diff / 24;
- long sixpacks = diff % 24 / 6;
- long beers = diff % 6;
- if (deliveredBeers >= neededBeers)
- {
- Console.WriteLine($"Cheers! Beer left: {cases} cases, {sixpacks} sixpacks and {beers} beers.");
- }
- else
- {
- Console.WriteLine($"Not enough beer. Beer needed: {cases} cases, {sixpacks} sixpacks and {beers} beers.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement