\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{programming1} \pdfinfo{ /Title (programming-1.pdf) /Creator (Cheatography) /Author (programming1) /Subject (Programming 1 Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A3A3A3} \definecolor{LightBackground}{HTML}{F3F3F3} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Programming 1 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{programming1} via \textcolor{DarkBackground}{\uline{cheatography.com/169592/cs/35522/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}programming1 \\ \uline{cheatography.com/programming1} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 24th November, 2022.\\ Updated 30th November, 2022.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{x{1.09494 cm} x{3.88206 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Variable types}} \tn % Row 0 \SetRowColor{LightBackground} & \{\{fa-book\}\} \{\{ar\}\}Page 35\{\{ar\}\} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{A {\emph{variable}} {\bf{stores}} a value during the running of a program} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{Type}} & {\bf{Description}} \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} {\bf{string}} & contains alpha numeric characters, persons name \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{int}} & a number value without decimal points, persons age \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} {\bf{double}} & a number with decimal points, an amount of money \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} {\bf{boolean}} & either true or false \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{c\# is a {\emph{strongly typed}} language. All variables {\bf{must}} have a type. \{\{nl\}\}We cannot "mix" types.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.84609 cm} x{4.13091 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Simple Print to Console}} \tn % Row 0 \SetRowColor{LightBackground} & \{\{fa-book\}\} \{\{ar\}\}Page 45\{\{ar\}\} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Examples}}\{\{nl\}\}Console.WriteLine("Hello World");\{\{nl\}\} Console.Write("and Hello Moon");} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{Line}} & {\bf{Description}} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} 1 & insert a carriage return and leave cursor on next line \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} 2 & leave cursor on same line \tn % Row Count 8 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.84609 cm} x{4.13091 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Placeholders}} \tn % Row 0 \SetRowColor{LightBackground} & \{\{fa-book\}\} \{\{ar\}\}Page 49\{\{ar\}\} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\emph{\$"\{varName1\} \{varName2\}"}}} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Examples}}\{\{nl\}\} Console.WriteLine(\$\{"Name : \{studentName\}");\{\{nl\}\}Console.WriteLine(\$"GPA : \{studentGpa\}");} \tn % Row Count 5 (+ 3) % Row 3 \SetRowColor{white} {\bf{Line}} & {\bf{Description}} \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} 1 & {\bf{\{}} and {\bf{\}}} enclose the variable name to display \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{You can use multiple placeholders in one string. \newline \{\{nl\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.09494 cm} x{3.88206 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Logical operators}} \tn % Row 0 \SetRowColor{LightBackground} & \{\{fa-book\}\} \{\{ar\}\}Page 62\{\{ar\}\} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{Operand}} & {\bf{Description}} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} A==B & checks two operands to see if equal. false \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} A!=B & check operands to see if not equal. true \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} A\textless{}B & is A less than B? false \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} A\textgreater{}=B & is A greater than or equal to B. true \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} A\textless{}=B & is A less than or equal to B? false \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{An operand is variable or value involved in operation. In examples above - A=10, B=5} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Loops - While Loop}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{\{fa-book\}\} \{\{ar\}\}Pages 79-83,86-87\{\{ar\}\}} \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{/{\emph{ \newline }} loop through a statement block 10 times \newline {\emph{ if condition is not satisfied, statements will not be executed \newline }}/ \newline int counter=0; \newline {\bf{while}} (counter \textless{}=10) \newline \{ \newline \seqsplit{Console.WriteLine(\$"Counter} value is \{counter\}"); \newline counter ++; \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Methods - declaration}} \tn % Row 0 \SetRowColor{LightBackground} & \{\{fa-book\}\} \{\{ar\}\}Page 93\{\{ar\}\} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{{[}static{]}}} {[}public|private{]} {\emph{return-type}} {\emph{MethodName}} ({[}{\emph{param-list}}{]}\}} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{Type}} & {\bf{Description}} \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} {\bf{{[}static{]}}} & no need to create instance, call directly \tn % Row Count 8 (+ 3) % Row 4 \SetRowColor{LightBackground} {[}{\emph{public}} | {\emph{private}}{]} & can only be called from within this class \tn % Row Count 11 (+ 3) % Row 5 \SetRowColor{white} {[}{\emph{void}} | {\emph{int}} | {\emph{double}} | {\emph{string}}{]} & return type, void infers nothing returned \tn % Row Count 14 (+ 3) % Row 6 \SetRowColor{LightBackground} {\emph{MethodName}} & use PascalCase for naming the method \tn % Row Count 16 (+ 2) % Row 7 \SetRowColor{white} ({[}{\emph{param-list}}{]}) & specify paramater type, separate with commas \tn % Row Count 19 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Tips n' Tricks for CA \#1}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Tip}} & {\bf{Reason}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Comment your code & allows you or someone else to more {\emph{easily}} understand the code now or in the future \tn % Row Count 6 (+ 5) % Row 2 \SetRowColor{LightBackground} Watch your variables and constant naming convention & Use camelCase for ordinary variables, and UPPERCASE for constants - it's {\emph{easy}} then to tell them apart \tn % Row Count 12 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.89586 cm} x{4.08114 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Variable Definition \& Assignment}} \tn % Row 0 \SetRowColor{LightBackground} & \{\{fa-book\}\} \{\{ar\}\}Pages 43-45\{\{ar\}\} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\emph{{[}type{]} \textless{}varName\textgreater{} = \textless{}value\textgreater{};}}} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Examples}}\{\{nl\}\}int studentAge=19;\{\{nl\}\}string studentName="Walter";\{\{nl\}\}double studentGpa=78.68; \{\{nl\}\}boolean studentRegistered;} \tn % Row Count 6 (+ 3) % Row 3 \SetRowColor{white} {\bf{Item}} & {\bf{Description}} \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{type}} & common types {\bf{int}}, {\bf{string}}, {\bf{double}}, {\bf{boolean}} \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} \textless{}varName\textgreater{} & the {\emph{name}} of variable in which we store value \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{studentRegisterd is not {\emph{initialised}} at declaration time above. it could be true or false.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.84609 cm} x{4.13091 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Read Keyboard Input - Strings}} \tn % Row 0 \SetRowColor{LightBackground} & \{\{fa-book\}\} \{\{ar\}\}Page 54\{\{ar\}\} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Example}}\{\{nl\}\}studentName=Console.ReadLine();} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{Line}} & {\bf{Description}} \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} 1 & read input from keyboard, assign to studentName \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Console.ReadLine() is a method without parameters. \newline It takes input from the keyboard as a string} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.68655 cm} x{0.86963 cm} x{3.02082 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Common Formatting Codes}} \tn % Row 0 \SetRowColor{LightBackground} & & \{\{fa-book\}\} \{\{ar\}\}Page 58-59\{\{ar\}\} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{3}{x{5.377cm}}{{\emph{\$"}}\{x:c\} \{y:p\} \{z:n3\}{\emph{"}}} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{Code}} & {\bf{Format}} & {\bf{Output}} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} C or c & \seqsplit{currency} & €1,245.44 \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} P or p & \seqsplit{percent} & 4.00\% \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} N or n & Number & 103,423.346 \tn % Row Count 9 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Formatting improve the output for the user. \newline \newline Above {\emph{x}}=1245.443, {\emph{y}}=0.04 and {\emph{z}}=103423.3456.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} x{4.4793 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{If stements - combining expressions}} \tn % Row 0 \SetRowColor{LightBackground} & \{\{fa-book\}\} \{\{ar\}\}Page 64-65\{\{ar\}\} \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{if ((condition1 \&\& condtion2) \newline \{ \newline // execute if condition1 AND condition2 true \newline \} \newline else if ((condition3 II condtion4) \newline \{ \newline // execute if condition3 OR condition4 \newline \} \newline else \newline // then execute this statement} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Loops - Do While}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{\{fa-book\}\} \{\{ar\}\}Page 84\{\{ar\}\}} \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{/{\emph{ \newline }} loop through a statement block 10 times \newline {\emph{ statement block will always execute at least once \newline }} even if counter was initially 11!! \newline */ \newline int counter=0; \newline {\bf{do}} \newline \{ \newline \seqsplit{Console.WriteLine(\$"Counter} value is \{counter\}"); \newline counter ++; // \newline \} {\bf{while}} (counter \textless{}=10)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.04057 cm} x{2.93643 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Methods - related terminology}} \tn % Row 0 \SetRowColor{LightBackground} & \{\{fa-book\}\} \{\{ar\}\}Page 92\{\{ar\}\} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{Item}} & {\bf{Description}} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} return type & a method can return a value - of type int, double, string. if nothing returned, then {\emph{return-type}} is void \tn % Row Count 8 (+ 5) % Row 3 \SetRowColor{white} sharing data between methods & {\emph{parameters}} - values passed to a method call. also known as arguments.\{\{nl\}\}{\emph{class level variables}} - available to all methods, scope is {\emph{global}} \tn % Row Count 15 (+ 7) % Row 4 \SetRowColor{LightBackground} calling a method & We must call the method to invoke it. \tn % Row Count 17 (+ 2) % Row 5 \SetRowColor{white} predefined methods & Includes \seqsplit{Console.WriteLine("Hello)} - has parameters\{\{nl\}\} Console.Readline() - no parameters \tn % Row Count 21 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.64241 cm} x{3.33459 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Tips n' Tricks for CA \#2}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Tip}} & {\bf{Reason}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Use code indentation & When using conditional (If), Loops (While, Do While, For) and Methods - indent your code. Make it {\emph{easier}} to read for everyone. \tn % Row Count 6 (+ 5) % Row 2 \SetRowColor{LightBackground} Follow the recipe & Make your input and output actually {\emph{look like}} what is presented on the CA question. \tn % Row Count 10 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Using naming conventions, comments}} \tn % Row 0 \SetRowColor{LightBackground} & \{\{fa-book\}\} \{\{ar\}\}Pages 39,53,93,30\{\{ar\}\} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{Type}} & {\bf{Description}} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} variables & camelCase, first letter is lowercase, other words first letter uppercase \tn % Row Count 6 (+ 3) % Row 3 \SetRowColor{white} constants & use uppercase, e.g. VATRATE \tn % Row Count 7 (+ 1) % Row 4 \SetRowColor{LightBackground} methods & PascalCase, first letter of each word is uppercase \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} comment our code & // what does this code do? \{\{nl\}\} /* reminds colleagues, our future selves \{\{fa-smile-o\}\} */ \tn % Row Count 13 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Coding conventions are important within a team. \newline \newline It is part of the common language of writing software code.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.84609 cm} x{4.13091 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Read Keyboard input - Numbers}} \tn % Row 0 \SetRowColor{LightBackground} & \{\{fa-book\}\} \{\{ar\}\}Page 55\{\{ar\}\} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Example}}\{\{nl\}\}studentAge = int.Parse(Console.ReadLine());\{\{nl\}\}studentGrade = \seqsplit{double.Parse(Console.ReadLine());}} \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} {\bf{Line}} & {\bf{Description}} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} 1 & Integer value is returned and assigned \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} 2 & Double value may contain decimals \tn % Row Count 9 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Extract a number from the keyboard input with .Parse()} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.84609 cm} x{4.13091 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Neater Printing in Tables}} \tn % Row 0 \SetRowColor{LightBackground} & \{\{fa-book\}\} \{\{ar\}\}Page 57\{\{ar\}\} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\emph{\$"\textless{}text\textgreater{}\{\textless{}expression\textgreater{},\textless{}field-width\textgreater{}\}\textless{}text\textgreater{}..."}}} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Examples}}} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{\$"Name :\{studentName,20\}"} \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\$"\{"Name",-20\} :\{studentName\}"} \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} {\bf{Line}} & {\bf{Description}} \tn % Row Count 7 (+ 2) % Row 6 \SetRowColor{LightBackground} 1 & right justify, 20 leading spaces before student name \tn % Row Count 9 (+ 2) % Row 7 \SetRowColor{white} 2 & left justify, 20 spaces after label "Name" \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{If statements - Examples}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{\{fa-book\}\} \{\{ar\}\}Pages 66-73\{\{ar\}\}} \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{if (studentGpa\textgreater{}=70) \newline \{ \newline \seqsplit{Console.WriteLine("Honours");} \newline \} \newline else if (studentGpa\textless{}70 \&\& studentGpa\textgreater{}=50) \newline \{ \newline \seqsplit{Console.WriteLine("Distinction");} \newline \} \newline else \seqsplit{Console.WriteLine("Fail");}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Loops - For Loop}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{\{fa-book\}\} \{\{ar\}\}Pages 85,87\{\{ar\}\}} \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{/{\emph{ \newline }} initial value of counter set in for statement \newline {\emph{ counter is incremented then statement block complete \newline }}/ \newline int counter; \newline {\bf{for}} (counter=0; counter \textless{}=10; counter++) \newline \{ \newline \seqsplit{Console.WriteLine(\$"Counter} value is \{counter\}"); \newline \} \newline \{\{nl\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Methods - full example}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{class Program \newline \{ \newline static void Main(string{[}{]} args) \newline \{ \newline static string salutation="Hello"; \newline string name=GetName(); \newline PrintGreeting(name); \newline \} \newline \newline static private string GetName() \newline \{ \newline Console.WriteLine("Enter First Name : "); \newline string \seqsplit{firstName=nameConsole.ReadLine();} \newline return firstName; \newline \} \newline static private void PrintGreeting(string name) \newline \{ \newline Console.WriteLine(\$"\{salutation\} \{name\}!"); \newline \} \newline \}\} // end class} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Bits and pieces}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\seqsplit{Console.OutputEncoding=System.Text.Encoding.UTF8;} // display special symbols like currency} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Carriage Return or "\textbackslash{}n" // A {\emph{carriage return}} moves the cursor onto the next line in our console display.} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Lab worksheet is a solution. Each question is a project} \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}