-Annie-

DozenEggs

Mar 28th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. namespace DozenEggs
  2. {
  3.     using System;
  4.  
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             int eggs = 0;
  10.             int dozens = 0;
  11.             int eggsSum = 0;
  12.             int dozensSum = 0;
  13.  
  14.             for (int i = 0; i < 7; i++)
  15.             {
  16.                 string[] inputLine = Console.ReadLine().Split(' ');
  17.  
  18.                 if (inputLine[1] == "eggs")
  19.                 {
  20.                     int eggQuantity = int.Parse(inputLine[0]);
  21.                     eggs += eggQuantity++;
  22.                 }
  23.  
  24.                 else if (inputLine[1] == "dozens")
  25.                 {
  26.                     int dozensQuantity = int.Parse(inputLine[0]);
  27.                     dozens += dozensQuantity;
  28.                 }
  29.             }
  30.  
  31.             eggsSum = eggs % 12;
  32.             dozensSum = dozens + (eggs / 12);
  33.  
  34.             Console.WriteLine(dozensSum + " dozens + " + eggsSum + " eggs");
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment