Q: Problem solving in C# Task - Joro, the Football Player

+4 votes

Joro loves a lot to play football. He used to play for his local village club “Pantera” Kaloyanovets. However, he is a programmer now and he is very busy. Now he is able to play only in the holidays and in the weekends.

Joro plays in 1/2 of the holidays and once in the weekends, but not every weekend – only when he is not tired and only when he is not going to his hometown. Joro goes at his hometown h weekends in the year. The other weekends are considered “normal”. Joro is tired in 1/3 of the normal weekends. When Joro is at his hometown, he always plays football with his old friends once, at Sunday. In addition, if the year is leap, Joro plays football 3 more times additionally, in non-weekend days. We assume the year has exactly 52 weekends.

Your task is to write a program that calculates how many times Joro plays football (rounded down to the nearest integer number).


The input data should be read from the console. It consists of three input values, each at separate line:

  • The string “t” for leap year (366 days) or “f” for year that is not leap (365 days).
  • The number p – number of holidays in the year (which are not Saturday or Sunday).
  • The number h – number of weekends that Joro spends in his hometown.

The input data will always be valid and in the format described. There is no need to check it explicitly.


  • The output data must be printed on the console.
  • On the only output line you must print an integer representing how many times Joro plays football for a year.


  • The numbers p is in range [0...300] and h is in range [0…52].
  • Allowed working time for your program: 0.25 seconds.
  • Allowed memory: 16 MB.


screenshot of the c# task - Joro, the football player

asked in C# category by user hues

1 Answer

+1 vote
Best answer

Bsically - the comment section solves the task :-) Here is my code:

using System;

class JoroFootballPlayer
    static void Main()
        string yearType = Console.ReadLine();
        decimal pHolidays = decimal.Parse(Console.ReadLine());
        decimal hInHome = decimal.Parse(Console.ReadLine());

        decimal weekendsInYear = 52;

        decimal weekendPlaysWihtoutHoliday = (weekendsInYear - hInHome);
        decimal weekendPlays = (weekendPlaysWihtoutHoliday * 0.6666666666666667m);//When he is not tired  - meaning 2/3 of the weekends (1-1/3(tired))
        decimal holidayPlays = (pHolidays * 0.5m);
        decimal allPlays = Math.Floor(weekendPlays + holidayPlays) + hInHome;

        switch (yearType)
            case "t": Console.WriteLine(allPlays + 3); break;
            case "f": Console.WriteLine(allPlays); break;


answered by user andrew
selected by user golearnweb