How to resolve the algorithm Five weekends step by step in the BBC BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Five weekends step by step in the BBC BASIC programming language

Table of Contents

Problem Statement

The month of October in 2010 has five Fridays, five Saturdays, and five Sundays.

Algorithm suggestions

Extra credit Count and/or show all of the years which do not have at least one five-weekend month (there should be 29).

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Five weekends step by step in the BBC BASIC programming language

Source code in the bbc programming language

      INSTALL @lib$+"DATELIB"
      DIM Month$(12)
      Month$() = "","January","February","March","April","May","June", \
      \   "July","August","September","October","November","December"
      
      num% = 0
      FOR year% = 1900 TO 2100
        PRINT ; year% ": " ;
        oldnum% = num%
        FOR month% = 1 TO 12
          IF FN_dim(month%,year%) = 31 IF FN_dow(FN_mjd(1,month%,year%)) = 5 THEN
            num% += 1
            PRINT Month$(month%), ;
          ENDIF
        NEXT
        IF num% = oldnum% PRINT "(none)" ELSE PRINT
      NEXT year%
      PRINT "Total = " ; num%


  

You may also check:How to resolve the algorithm Water collected between towers step by step in the Phix programming language
You may also check:How to resolve the algorithm Strip block comments step by step in the TUSCRIPT programming language
You may also check:How to resolve the algorithm Plot coordinate pairs step by step in the VBA programming language
You may also check:How to resolve the algorithm Sorting algorithms/Cocktail sort step by step in the Lua programming language
You may also check:How to resolve the algorithm Variable size/Get step by step in the BASIC256 programming language