Shahezad Contractor
Professor Ebrahimi
WHAT IS AN ALGORITHM? WHERE DOES THE
ALGORITHM COME FROM?
When it comes to programming and problem solving, the word "algorithm" is frequently used. At first glance, most people associate the word algorithm with a mathematical term such as Logarithm. In programming, algorithm refers to the problem solving steps that are needed to find a solution to a problem, such as finding the shortest path from one city to another or computing employee wages. Where does the word algorithm come from? It came from Persian scientist Alkharazmi who wrote the book around 825 A.D. called "Algebr and Moghabeleh" which translates to "Reduction and Calculation".
The following program is written in pseudo code and needs to be converted to visual basic.
THE FOLLOWING PROGRAM IS FOR AVERAGING
MULTIPLE SPACE-TEMPERATURE SENSORS.
LIGHT1, LIGHT2, AND LIGHT3 are inputs.
DOEVERY 1 M
IF LIGHT1 = ON THEN BEGIN
IF ST1 BETWEEN CURRENTCURRENTHEATINGSETPOINTA CURRENTCURRENTCOOLINGSETPOINTA THEN BEGIN
A2 = SPACETEMPERATURE1
B2 = 1
END
ELSE BEGIN
A2 = SPACETEMPRETURE1 * 2
B2 = 2
END
ELSE BEGIN
A2 = 0
B2 = 0
END
IF LIGHT2 = ON THEN BEGIN
IF ST2 BETWEEN CURRENTHEATINGSETPOINTA CURRENTCOOLINGSETPOINTA THEN BEGIN
A2 = A2 + SPACETEMPERATURE2
B2 = B2 + 1
END
ELSE BEGIN
A2 = A2 + SPACETEMERATURE2 * 2
B2 = B2 + 2
END
END
IF LIGHT3 = ON THEN BEGIN
IF SPACETEMPERATURE3 BETWEEN CURRENTHEATINGSETPOINTA CURRENTCOOLINGSETPOINTA BEGIN
A2 = A2 + SETTEMPERATURE3
B2 = B2 + 1
END
ELSE BEGIN
A2 = A2 + SPACETEMPERATURE3 * 2
B2 = B2 + 2
END
END
IF B2 > = THEN
BOXSPACETEMP = A2 / B2
ELSE
BOXSPACETEMP = AVG (SPACETEMPERATURE1, SPACETEMPERATURE2, SPACETEMPERATURE3)
DOEVERY 1 M
IF LIGHT1 = ON THEN BEGIN
IF ST1 >= CURRENTCURRENTHEATINGSETPOINTA AND ST1 <= CURRENTCURRENTCOOLINGSETPOINTA THEN
A2 = SPACETEMPERATURE1
B2 = 1
END IF
ELSE
A2 = SPACETEMPRETURE1 * 2
B2 = 2
END IF
ELSE
A2 = 0
B2 = 0
END IF
IF LIGHT2. = ON THEN
IF ST2 >= CURRENTHEATINGSETPOINTA AND ST2 <= CURRENTCOOLINGSETPOINTA THEN
A2 = A2 + SPACETEMPERATURE2
B2 = B2 + 1
END IF
ELSE
A2 = A2 + SPACETEMERATURE2 * 2
B2 = B2 + 2
END IF
END IF
IF LIGHT3 = ON
IF SPACETEMPERATURE3 BETWEEN CURRENTHEATINGSETPOINTA CURRENTCOOLINGSETPOINTA
A2 = A2 + SETTEMPERATURE3
B2 = B2 + 1
END IF
ELSE
A2 = A2 + SPACETEMPERATURE3 * 2
B2 = B2 + 2
END IF
END
IF B2 > 0 THEN
BOXSPACETEMP = A2 / B2
ELSE
BOXSPACETEMP = SPACETEMPERATURE1 + SPACETEMPERATURE2 + SPACETEMPERATURE3 / 3


SPACETEMPERATURE1 = TextBox1.Text
SPACETEMPERATURE2 = TextBox2.Text
SPACETEMPERATURE3 = TextBox3.Text
If LIGHT1.Checked Then If SPACETEMPERATURE1 >= CURRENTHEATINGSETPOINTA And SPACETEMPERATURE1 <= CURRENTCOOLINGSETPOINTA ThenA2 = SPACETEMPERATURE1
B2 = 1
ElseA2 = SPACETEMPERATURE1 * 2
B2 = 2
End If ElseA2 = 0
B2 = 0
End If If LIGHT2.Checked Then If SPACETEMPERATURE2 >= CURRENTHEATINGSETPOINTA And SPACETEMPERATURE2 <= CURRENTCOOLINGSETPOINTA ThenA2 = A2 + SPACETEMPERATURE2
B2 = B2 + 1
End If ElseA2 = A2 + SPACETEMPERATURE2 * 2
B2 = B2 + 2
End If If LIGHT3.Checked Then If SPACETEMPERATURE3 >= CURRENTHEATINGSETPOINTA And SPACETEMPERATURE3 <= CURRENTCOOLINGSETPOINTA ThenA2 = A2 + SPACETEMPERATURE3
B2 = B2 + 1
End If ElseA2 = A2 + SPACETEMPERATURE3 * 2
B2 = B2 + 2
End If If B2 > 0 ThenBOXSPACETEMP = A2 / B2
ElseBOXSPACETEMP = (SPACETEMPERATURE1 + SPACETEMPERATURE2 + SPACETEMPERATURE3) / 3
End IfTextBox4.Text = BOXSPACETEMP
End Sub
1 Amna