Advertisement
vencinachev

Untitled

Mar 15th, 2019
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Program
  6. {
  7.     public static void Main()
  8.     {
  9.         int wines = 300;
  10.         int winesD = 0;
  11.         int winesO = 0;
  12.         int beers = 200;
  13.         int beersD = 0;
  14.         int beersO = 0;
  15.        
  16.         while (true)
  17.         {
  18.             String input = Console.ReadLine();
  19.             if (input == "END"){
  20.                 break;
  21.             }
  22.             String[] str = input.Split(':');
  23.             String drink = str[0];
  24.             int quantity = int.Parse(str[1]);
  25.            
  26.             if (drink == "Beers")
  27.             {
  28.                 beers += quantity;
  29.                 if (quantity > 0)
  30.                 {
  31.                     beersD++;
  32.                 }
  33.                 else if (quantity > 0)
  34.                 {
  35.                     beersO++;
  36.                 }
  37.             }
  38.             else if (drink == "Wines")
  39.             {
  40.                 wines += quantity;
  41.                 if (quantity > 0)
  42.                 {
  43.                     winesD++;
  44.                 }
  45.                 else
  46.                 {
  47.                     winesO++;
  48.                 }
  49.             }
  50.         }
  51.        
  52.         Console.WriteLine("Wines: " + wines);
  53.         Console.WriteLine("Deliveries: " + winesD);
  54.         Console.WriteLine("Orders: " + winesO);
  55.         Console.WriteLine("Beers: " + beers);
  56.         Console.WriteLine("Deliveries: " + beersD);
  57.         Console.WriteLine("Orders: " + beersO);
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement