How to resolve the algorithm Calendar step by step in the SPL programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Calendar step by step in the SPL programming language
Table of Contents
Problem Statement
Create a routine that will generate a text calendar for any year.
Test the calendar by generating a calendar for the year 1969, on a device of the time.
Choose one of the following devices:
(Ideally, the program will generate well-formatted calendars for any page width from 20 characters up.) Kudos (κῦδος) for routines that also transition from Julian to Gregorian calendar. This task is inspired by Real Programmers Don't Use PASCAL by Ed Post, Datamation, volume 29 number 7, July 1983. For further Kudos see task CALENDAR, where all code is to be in UPPERCASE. For economy of size, do not actually include Snoopy generation in either the code or the output, instead just output a place-holder.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Calendar step by step in the SPL programming language
Source code in the spl programming language
year = 1969
#.output(#.str(year,">68<"))
> row, 0..3
> col, 1..3
cal[col] = mcal(row*3+col,year)
size = #.size(cal[col],1)
<
> i, 1..8
str = ""
> col, 1..3
? col>1, str += " "
line = ""
? #.size(cal[col],1)!
str += #.str(line,"<20<")
<
#.output(str)
<
<
mcal(m,y)=
months = ["January","February","March","April","May","June","July","August","September","October","November","December"]
days = [31,28,31,30,31,30,31,31,30,31,30,31]
? y%4=0, days[2] = 29
lines = #.array(0)
lines[1] = #.str(months[m],">20<")
lines[2] = "Mo Tu We Th Fr Sa Su"
n = 3
> i, 1..#.weekday(1,m,y)-1
lines[n] += " "
<
> d, 1..days[m]
wd = #.weekday(d,m,y)
lines[n] += #.str(d,">2>")
? wd<7, lines[n] += " "
? wd=7, n += 1
<
<= lines
.
You may also check:How to resolve the algorithm Parsing/RPN calculator algorithm step by step in the C++ programming language
You may also check:How to resolve the algorithm Abbreviations, simple step by step in the 11l programming language
You may also check:How to resolve the algorithm Draw a sphere step by step in the PostScript programming language
You may also check:How to resolve the algorithm Deepcopy step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Ackermann function step by step in the Klingphix programming language