Advertisement
nmnikolov

01. MelonsAndWatermelons

Jul 25th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.61 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. class MelonsAndWatermelons
  8. {
  9.     static void Main()
  10.     {
  11.         int s = int.Parse(Console.ReadLine());
  12.         int d = int.Parse(Console.ReadLine());
  13.        
  14.         int watermelons = 0;
  15.         int melons = 0;
  16.  
  17.         for (int i = 0; i < d; i++)
  18.     {
  19.             watermelons += Watemelons(s);
  20.             melons += Melons(s);
  21.             s++;
  22.  
  23.             if (s == 8)
  24.             {
  25.                 s = 1;
  26.             }          
  27.     }
  28.  
  29.         if (watermelons == melons)
  30.         {
  31.             Console.WriteLine("Equal amount: {0}", watermelons);
  32.         }
  33.         else if (watermelons > melons)
  34.         {
  35.             Console.WriteLine("{0} more watermelons", watermelons - melons);
  36.         }
  37.         else
  38.         {
  39.             Console.WriteLine("{0} more melons", melons - watermelons );
  40.         }
  41.     }
  42.  
  43.     public static int Melons(int day)
  44.     {
  45.         int melons = 0;
  46.         switch (day)
  47.         {
  48.            
  49.             case 2:
  50.             case 5:
  51.             case 6:
  52.                 melons += 2; break;
  53.             case 3:
  54.                 melons++; break;
  55.  
  56.         }
  57.         return melons;
  58.     }
  59.  
  60.     public static int Watemelons (int day)
  61.     {
  62.         int watermelons = 0;
  63.         switch (day)
  64.         {
  65.  
  66.             case 1:
  67.             case 3:
  68.             case 6:
  69.                 watermelons++; break;
  70.             case 4:
  71.             case 5:
  72.                 watermelons += 2; break;            
  73.         }
  74.         return watermelons;
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement