Quick reference

Recurring formulas and task patterns

Use this page as a short memory aid for formulas, file placement, and starter templates that show up again and again.

Main idea

When you forget a formula or starter pattern, check here first.

Reference

Reusable formulas and starter patterns

This page is a short memory aid. It is here so you do not have to search the whole site for the same formula again and again.

Use it when you remember the task type but not the exact line of code or formula.

Console starter

One clean input -> process -> output pattern.

Forms event flow

A short reminder of what goes in the Designer and what goes in Form1.cs.

Browser starter

A small file set for HTML, CSS, and JavaScript.

Formulas

Three formulas that repeat often

These are the formulas people look up again and again on this site.

TaskFormula or ruleReminder
Rectangle perimeter2 * (width + height)Use both sides twice.
Rectangle areawidth * heightOnly one multiplication.
Quadratic discriminantb * b - 4 * a * cCheck a = 0 first.
Driving rangefuel / consumption * 100Consumption is liters per 100 km.
Leap year(year % 4 == 0 && year % 100 != 0) || year % 400 == 0100 and 400 are the easy places to make mistakes.
Stats

Average vs. median

Both are middle-type values, but they do not mean the same thing.

Useful for: C# ConsoleUseful for: Flowcharts

Quick rule

  1. Average: add all values and divide by the count.
  2. Median: sort the values and take the middle one.
  3. If there is an even count, average the two middle values.

Small examples

  • 1, 2, 100 -> average 34.33, median 2
  • 1, 2, 3, 4 -> median 2.5
WinForms

Typical event flow

When a WinForms example feels confusing, the problem is usually file placement, not the calculation itself.

Useful for: C# Forms

Normal order

  1. Place the controls on the form in the Designer.
  2. Set the Name of each control.
  3. Open Form1.cs.
  4. Attach the click event or double-click the button.
  5. Read values, validate them, calculate, then write the result to a label.

Button-click pattern

  • Read input from TextBox
  • Use TryParse if the input should be a number
  • Calculate
  • Write result into Label or MessageBox
Electronics

Resistor band reminder

A short table is often enough for common three-band resistor tasks.

ColorDigitMultiplier
Black01
Brown110
Red2100
Orange31,000
Yellow410,000
Green5100,000
Blue61,000,000
Violet7-
Browser

One clean browser task template

Use this when a teacher says: make a page with HTML, CSS, and a small button action.

Useful for: HTML/CSS/JS

Build order

  1. Create the three files in one folder.
  2. Paste the HTML first.
  3. Link the CSS and JavaScript files correctly.
  4. Open the HTML file and test the button.

Good check

  • If the style does not load, check the CSS file name and href.
  • If the button does nothing, check the JavaScript file name and src.
FILE: index.html
index.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Starter page</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <h1>Starter page</h1>
  <button id="action-button" type="button">Click me</button>

  <script src="script.js"></script>
</body>
</html>
FILE: style.css
style.css
body {
  font-family: Arial, sans-serif;
  margin: 24px;
}

button {
  padding: 10px 14px;
  font: inherit;
}
FILE: script.js
script.js
document.getElementById("action-button").addEventListener("click", () => {
  alert("It works.");
});
Console

One clean console starter

This is the smallest useful console pattern: input, process, output.

Useful for: C# Console

Use it like this

  1. Replace the input line with the value you need.
  2. Replace the process line with your formula or condition.
  3. Keep the output line clear and short.

Good check

  • If the task needs numbers, change the input line to TryParse.
  • If the task needs a loop, wrap the input-process-output part in a loop.
FILE: Program.cs
Program.cs
Console.Write("Input: ");
string input = Console.ReadLine() ?? "";

string result = input.ToUpper();

Console.WriteLine($"Result: {result}");