Advertisement
Filkolev

Melons And Watermelons

Jul 25th, 2014
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.95 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.  
  8. class MelonsAndWatermelons
  9. {
  10.     static void Main()
  11.     {
  12.         int startingDay = int.Parse(Console.ReadLine());
  13.         int numberOfDays = int.Parse(Console.ReadLine());
  14.         int countOfMelons = 0;
  15.         int countOfWatermelons = 0;
  16.      
  17.  
  18.         string[] days = { "mon", "tue", "wed", "thur", "fri", "sat", "sun" };
  19.  
  20.         for (int i = 0; i < numberOfDays; i++)
  21.         {
  22.  
  23.             int dayOfWeek = startingDay - 1 + i;
  24.  
  25.             if (dayOfWeek >= 7)
  26.             {
  27.                 dayOfWeek = dayOfWeek % 7;
  28.             }
  29.  
  30.             string currentDay = days[dayOfWeek];
  31.  
  32.             switch (currentDay)
  33.             {
  34.                 case "mon":
  35.                     countOfWatermelons++;
  36.                     break;
  37.                 case "tue":
  38.                     countOfMelons += 2;
  39.                     break;
  40.                 case "wed":
  41.                     countOfMelons++;
  42.                     countOfWatermelons++;
  43.                     break;
  44.                 case "thur":
  45.                     countOfWatermelons += 2;
  46.                     break;
  47.                 case "fri":
  48.                     countOfMelons += 2;
  49.                     countOfWatermelons += 2;
  50.                     break;
  51.                 case "sat":
  52.                     countOfWatermelons++;
  53.                     countOfMelons += 2;
  54.                     break;
  55.  
  56.             }
  57.         }
  58.  
  59.         if (countOfMelons == countOfWatermelons)
  60.         {
  61.             Console.WriteLine("Equal amount: {0}", countOfMelons);
  62.         }
  63.  
  64.         else if (countOfMelons > countOfWatermelons)
  65.         {
  66.             Console.WriteLine("{0} more melons", countOfMelons - countOfWatermelons);
  67.         }
  68.  
  69.         else
  70.         {
  71.             Console.WriteLine("{0} more watermelons", countOfWatermelons - countOfMelons);    
  72.         }
  73.  
  74.  
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement