Advertisement
dimipan80

Exam 1. Joro_TheFootball_Player

Jun 1st, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 KB | None | 0 0
  1. namespace _15.JoroTheFootballPlayer
  2. {
  3.     using System;
  4.  
  5.     public class HowManyDaysJoroPlaysFootball
  6.     {
  7.         private const byte WeekendsOnYear = 52;
  8.  
  9.         public static void Main(string[] args)
  10.         {
  11.             checked
  12.             {
  13.                 string typeYear = Console.ReadLine();
  14.                 ushort countHolidays = ushort.Parse(Console.ReadLine());
  15.                 byte hometownWeekends = byte.Parse(Console.ReadLine());
  16.  
  17.                 // The First we must calculate how many Days in all Weekends Joro playing football:
  18.                 double playingDays = CalculatePlayingDaysOfAllWeekends(hometownWeekends);
  19.  
  20.                 // Next we must calculating Playing Days in all Holidays and adds to calculated from Weekends:
  21.                 playingDays += countHolidays * 0.5;
  22.  
  23.                 // The Last thing is to Check Year is Leap or not. If Year is Leap adding 3 more days:
  24.                 if (typeYear == "t")
  25.                 {
  26.                     playingDays += 3;
  27.                 }
  28.  
  29.                 /* Output must been whole number. Here, we take result, wich is of type double and
  30.                 * and casting him to integer: */
  31.                 int totalPlayDays = (int)playingDays;
  32.                 Console.WriteLine(totalPlayDays);
  33.             }
  34.         }
  35.  
  36.         private static double CalculatePlayingDaysOfAllWeekends(byte homeWeekends)
  37.         {
  38.             // When Joro goes to hometown, he play 1 day on Weekend:
  39.             double playDays = homeWeekends;
  40.  
  41.             // Calculate Playing Days from normal Weekends:
  42.             byte countNormalWeekends = (byte)(WeekendsOnYear - homeWeekends);
  43.             playDays += countNormalWeekends * 2 / 3.0;
  44.             return playDays;
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement