JMA201-01 |
||||
|
An algorithm is a listing of the steps that we will need to create a program. It is, in essence, an outline for developing your program - you should think about the process your program will follow before you begin attempting to implement. Many different structures will appear in your program - different subroutines, event handlers, and so on; an algorithm allows you to prepare these elements before you write them, so you can plan effectively!
Algorithms are often written either in English, or as pseudocode - code written with some keywords to help remind yourself of the functions you might need to implement, but code that is NOT syntactically correct.
Finding My Formula
I researched the BMI formula - it is expressed in this form:
BMI = |
(weight in pounds * 703 ) |
———————————— | |
height in inches² |
We now need to convert this to programming form, using Order Of Operations:
Next, I would convert the "friendly" value names to VB appropriate variable names:
Now, write as one expression:
Simple Algorithm
For a Body Mass Index (BMI) calculator, here is a sample algorithm we might write, in English:
Form Elements
What form elements do I need? The values I need should suggest the textboxes I'll need on my form - I'll need:
Pseudocode
And, now we can start writing some pseudocode: