How to resolve the algorithm Five weekends step by step in the PL/I programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Five weekends step by step in the PL/I 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 PL/I programming language
Source code in the pl/i programming language
weekends: procedure options (main); /* 28/11/2011 */
declare tally fixed initial (0);
declare (d, dend, dn) fixed (10);
declare (date_start, date_end) picture '99999999';
declare Leap fixed (1);
date_start = '01011900';
do date_start = date_start to '01012100';
d = days(date_start, 'DDMMYYYY');
date_end = date_start + 30110000;
dend = days(date_end, 'DDMMYYYY');
Leap = dend-d-364;
do dn = d, d+59+Leap, d+120+Leap, d+181+Leap, d+212+Leap,
d+273+Leap, d+334+Leap;
if weekday(dn) = 6 then
do;
put skip list (daystodate(dn, 'MmmYYYY') || ' has 5 weekends' );
tally = tally + 1;
end;
end;
end;
put skip list ('Total number of months having 3-day weekends =', tally);
end weekends;
You may also check:How to resolve the algorithm Calendar step by step in the PL/I programming language
You may also check:How to resolve the algorithm Riordan numbers step by step in the PL/I programming language
You may also check:How to resolve the algorithm Element-wise operations step by step in the PL/I programming language
You may also check:How to resolve the algorithm A+B step by step in the PL/I programming language
You may also check:How to resolve the algorithm Host introspection step by step in the PL/I programming language