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 BeerStock
- {
- class BeerStock
- {
- static void Main(string[] args)
- {
- int neededBeers = int.Parse(Console.ReadLine());
- string line = Console.ReadLine();
- int beersCout = 0;
- int enoughtCases = 0;
- int enoughtSixPacks = 0;
- int enoughtBeers = 0;
- int notEnoughtCases = 0;
- int notEnoughtSixPacks = 0;
- int notEnoughtBeers = 0;
- while (line != "Exam Over")
- {
- string[] parameters = line.Split();
- int amount = int.Parse(parameters[0]);
- string type = parameters[1];
- switch (type)
- {
- case "cases":
- beersCout += amount * 24;
- break;
- case "sixpacks":
- beersCout += amount * 6;
- break;
- default:
- beersCout += amount;
- break;
- }
- line = Console.ReadLine();
- }
- if (beersCout >= neededBeers)
- beersCout = beersCout - (beersCout / 100);
- if (beersCout >= neededBeers)
- {
- int leftBeers = beersCout - neededBeers;
- if (leftBeers >= 24)
- {
- enoughtCases = leftBeers / 24;
- leftBeers = leftBeers - (enoughtCases * 24);
- }
- if (leftBeers >= 6)
- {
- enoughtSixPacks = leftBeers / 6;
- leftBeers = leftBeers - (enoughtSixPacks * 6);
- }
- if (leftBeers >= 1)
- {
- enoughtBeers = leftBeers;
- }
- Console.WriteLine($"Cheers! Beer left: {enoughtCases} cases, {enoughtSixPacks} sixpacks and {enoughtBeers} beers.");
- }
- else
- {
- int leftBeers = neededBeers - beersCout;
- if (leftBeers >= 24)
- {
- notEnoughtCases = leftBeers / 24;
- leftBeers = leftBeers - (notEnoughtCases * 24);
- }
- if (leftBeers >= 6)
- {
- notEnoughtSixPacks = leftBeers / 6;
- leftBeers = leftBeers - (notEnoughtSixPacks * 6);
- }
- if (leftBeers >= 1)
- {
- notEnoughtBeers = leftBeers;
- }
- Console.WriteLine($"Not enough beer. Beer needed: {notEnoughtCases} cases, {notEnoughtSixPacks} sixpacks and {notEnoughtBeers} beers.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement