Thursday, December 9, 2010

Sequence structure Algorithm Programming


Runs / SEQUENCE

Is an activity or action in a row and interconnected, where an act done after the previous action is completed.

The form of this activity are:

- Activities carried out sequentially

- No repetitive activity

- In accordance with the program structure

- Done from beginning to end

Public Forms

'Variable 1: Type data1

'Variabe2 1: Type data2


'Input value1

'Input value2

'Process Ekspresi1

'Process Ekspresi2

'Process Ekspresi3

'Done

Different action sequences in the Sequence / runs can produce different output.

Private Sub Command1_Click ()

'EXAMPLE 1 SEQUENCE

Dim A, B As Integer

A = InputBox ("Enter A: '")

B = A

A = 2 * A

Label1.Caption = B

Print "result:"; B

End Sub

Example Sequence 2

Private Sub GayaHKNewtonIII_Click ()

Dim G, M, a, M As Single

Print "Program To Count Style On Newton's Law III"

M = InputBox ("Value Objects Mass (Kg):" "," Variable M ")

a = InputBox ("Value Acceleration (m/s2):" "," variable a ")

F = InputBox ("Value of Friction (Newton ):'"," Variable F ")

G = M * a * F

Print "Style Motion required ="; G; "Newton"

End Sub

Making Program

Stage in making the program there are 3 main parts: Input-Process-Output

Steps to Create a simple program:

1. Choose variable names

2. Determine the formula used

3. Write a complete program. The first few lines are used to define the data and reading the input data, the following lines declare

a variable output as a result of the operation process input variables

Sequence Examples

1. Program To Change Become Celsius Fahrenheit

Variable: C, F, R Integer

Input F

C = (F-32) * 5 / 9

R = (F-32) * 4 / 9

2. Program change into meters I Kilometers

KM Process Input M = KM * 1000

3. Program Calculating Area and Circumference Circle

Phi = 3:14 Variables Constants: r, L, K Integer

L = Phi * r * r K = Phi * 2 * r

4. Program change Hours to Minutes M = J * 60

5. Calculating Potential Energy Things Ep (Joule) = M * G * H

Exercise Problems

1. Create a program Calculating Force press on Newton's Second Law
2. Create a program object Counting Hollywood motion, Newton's Law III
3. Create a program to calculate Area and around the Triangle that are known side
4. Dim X, Y as a Boolean

Dim A, B as Integer

X = True: Y = False A = 23 B = 7

a. (A mod B) <= 4 imp Y


b. (X XOR Y) imp (X and Y)

5. Create a Program Change value in seconds to Hours, Minutes, Seconds

6. Create a program to change fractions into Persent from Input 2 Integer?

Hint question:

1. P = F / a P = Force Press on Objects (Joule) F = force acting on the field (Newton) a = acceleration (m/s2)

2. G = M * a * F

3. K = A + B + C

S = ½ K

L = √ S (S-A) (S-B) (S-C)

Answer:

Private Sub DetikTOJamMenitDetik_Click ()

Dim Seconds, Minutes, Hours, X, Value As Single

Value = InputBox ("Second Value:" ")

Hours = Int (Value / 3600) 'Looking Hours

Label1.Caption = Hours

X = Value Mod 3600

Label2.Caption = X

Minutes = Int (X / 60)

Label3.Caption = Minute

Seconds = X - (60 * Minutes)

Label4.Caption = Seconds

Print Value: "SECONDS"

Print Jam; "JAM"

Print Minutes; "MIN"

Print Seconds; "SECONDS"

End Sub

Private Sub GayaHKNewtonIII_Click ()

Dim G, M, a, M As Single

Print "Program To Count Style On Newton's Law III"

M = InputBox ("Value Objects Mass (Kg):" "," Variable M ")

a = InputBox ("Value Acceleration (m/s2):" "," variable a ")

F = InputBox ("Value of Friction (Newton ):'"," Variable F ")

G = M * a - F

Print "Style Motion required ="; G; "Newton"

End Sub

Example:

? 3500 mod 3600

3500

? 5 mod 10

5

? 100 Mod 60

40

? 60 mod 60

0

? 60 mod 3600

60

? 70 mod 3600

70

No comments:

Post a Comment

Comment