## Flowchart Bilangan Prima(looping)

December 24th, 2010 No Comments »

## Pseudocode Menghitung 3 Bilangan Ganjil Berurutan

December 14th, 2010 No Comments »

Pseudo Code

Declaring :

Bilangan               : Integer

Jumlah                  : Integer

Counter               : Integer

Description :

a= Bilangan ganjil

b=a+2

c=b+2

p← p+1

x← a+b+c

IF p=3 THEN

PRINT”Total”

ELSE

ENDIF

## Flowchart Menghitung 3 Bilangan Ganjil Berurutan

December 14th, 2010 No Comments »

Flowchart :

## My Project

November 29th, 2010 No Comments »

Project Bilangan

Script Project Bilangan

## Pseudo Code Algoritma Bilangan Genap Kurang dari 8 Habis Dibagi 3

October 13th, 2010 No Comments »

Algoritma Bilangan Genap Kurang dari Delapan_Habis Dibagi Tiga{ Dibaca tiga buah bilangan genap  kurang dari delapan dari piranti input. Carilah bilangan genap habis dibagi tiga diantara ketiga bilangan tersebut }

Deklarasi :
Bil1,Bil2,Bil3 :  interger {bilangan yang dicari genap habis dibagi tiga}
TIDAK COCOK          : interger {variabel bantu}
COCOK               : interger {variabel bantu}

Deskripsi :

If Bil1 = HABIS DIBAGI TIGA then

Bil1 = COCOK

If Bil1 = TIDAK HABIS DIBAGI TIGA then

Bil1 = TIDAK COCOK

If Bil2 = HABIS DIBAGI TIGA then

Bil2 = COCOK

If Bil2 = TIDAK HABIS DIBAGI TIGA then

Bil2 = TIDAK COCOK

If Bil3 = HABIS DIBAGI TIGA then

Bil3 = COCOK
Write (COCOK)

## Pseudo Code

October 12th, 2010 No Comments »

### PSEUDOCODE STANDARD

Pseudocode is a kind of structured english for describing algorithms. It allows the designer to focus on the logic of the algorithm without being distracted by details of language syntax.  At the same time, the pseudocode needs to be complete.  It describe the entire logic of the algorithm so that implementation becomes a rote mechanical task of translating line by line into source code.

In general the vocabulary used in the pseudocode should be the vocabulary of the problem domain, not of the implementation domain.  The pseudocode is a narrative for someone who knows the requirements (problem domain) and is trying to learn how the solution is organized.  E.g.,

Extract the next word from the line (good)
set word to get next token (poor)Append the file extension to the name (good)
name = name + extension (poor)

FOR all the characters in the name (good)
FOR character = first to last (ok)

Note that the logic must be decomposed to the level of a single loop or decision. Thus “Search the list and find the customer with highest balance” is too vague because it takes a loop AND a nested decision to implement it. It’s okay to use “Find” or “Lookup” if there’s a predefined function for it such as `String.indexOf()`.

Each textbook and each individual designer may have their own personal style of pseudocode. Pseudocode is not a rigorous notation, since it is read by other people, not by the computer. There is no universal “standard” for the industry, but for instructional purposes it is helpful if we all follow a similar style. The format below is recommended for expressing your solutions in our class.

The “structured” part of pseudocode is a notation for representing six specific structured programming constructs: SEQUENCE, WHILE, IF-THEN-ELSE, REPEAT-UNTIL, FOR, and CASE. Each of these constructs can be embedded inside any other construct. These constructs represent the logic, or flow of control in an algorithm.

It has been proven that three basic constructs for flow of control are sufficient to implement any “proper” algorithm.

SEQUENCE is a linear progression where one task is performed sequentially after another.
WHILE is a loop (repetition) with a simple conditional test at its beginning.
IF-THEN-ELSE is a decision (selection) in which a choice is made between two alternative courses of action.

Although these constructs are sufficient, it is often useful to include three more constructs:

REPEAT-UNTIL is a loop with a simple conditional test at the bottom.
CASE is a multiway branch (decision) based on the value of an expression. CASE is a generalization of IF-THEN-ELSE.
FOR is a “counting” loop.

SEQUENCE

Sequential control is indicated by writing one action after another, each action on a line by itself, and all actions aligned with the same indent. The actions are performed in the sequence (top to bottom) that they are written.

Example (non-computer)

Brush teeth
Wash face
Comb hair
Smile in mirror

Example

COMPUTE area as height times width

Common Action Keywords

Several keywords are often used to indicate common input, output, and processing operations.

Output: PRINT, DISPLAY, SHOW
Compute: COMPUTE, CALCULATE, DETERMINE
Initialize: SET, INIT

IF-THEN-ELSE

Binary choice on a given Boolean condition is indicated by the use of four keywords: IF, THEN, ELSE, and ENDIF. The general form is:

IF condition THEN

sequence 1

ELSE

sequence 2

ENDIF

The ELSE keyword and “sequence 2″ are optional. If the condition is true, sequence 1 is performed, otherwise sequence 2 is performed.

Example

IF HoursWorked > NormalMax THEN

Display overtime message

ELSE

Display regular time message

ENDIF

WHILE

The WHILE construct is used to specify a loop with a test at the top. The beginning and ending of the loop are indicated by two keywords WHILE and ENDWHILE. The general form is:

WHILE condition

sequence

ENDWHILE

The loop is entered only if the condition is true. The “sequence” is performed for each iteration. At the conclusion of each iteration, the condition is evaluated and the loop continues as long as the condition is true.

Example

WHILE Population < Limit

Compute Population as Population + Births - Deaths

ENDWHILE

Example

WHILE employee.type NOT EQUAL manager AND personCount < numEmployees

INCREMENT personCount
CALL employeeList.getPerson with personCount RETURNING employee

ENDWHILE

CASE

A CASE construct indicates a multiway branch based on conditions that are mutually exclusive. Four keywords, CASE, OF, OTHERS, and ENDCASE, and conditions are used to indicate the various alternatives. The general form is:

CASE expression OF

condition 1 : sequence 1
condition 2 : sequence 2

condition n : sequence n
OTHERS:
default sequence

ENDCASEThe OTHERS clause with its default sequence is optional. Conditions are normally numbers or characters

indicating the value of “expression”, but they can be English statements or some other notation that specifies the condition under which the given sequence is to be performed. A certain sequence may be associated with more than one condition.

Example

```        CASE  Title  OF
Mr      : Print "Mister"
Mrs     : Print "Missus"
Miss    : Print "Miss"
Ms      : Print "Mizz"
Dr      : Print "Doctor"
ENDCASE```

Example

```        CASE  grade  OF
A       : points = 4
B       : points = 3
C       : points = 2
D       : points = 1
F       : points = 0
ENDCASE```

REPEAT-UNTIL

This loop is similar to the WHILE loop except that the test is performed at the bottom of the loop instead of at the top. Two keywords, REPEAT and UNTIL are used. The general form is:

REPEAT

sequence

UNTIL condition

The “sequence” in this type of loop is always performed at least once, because the test is peformed after the sequence is executed. At the conclusion of each iteration, the condition is evaluated, and the loop repeats if the condition is false. The loop terminates when the condition becomes true.

FOR

This loop is a specialized construct for iterating a specific number of times, often called a “counting” loop.  Two keywords, FOR and ENDFOR are used. The general form is:

FOR iteration bounds

sequence

ENDFOR

In cases where the loop constraints can be obviously inferred it is best to describe the loop using problem domain vocabulary.

Example

FOR each month of the year (good)
FOR month = 1 to 12 (ok)FOR each employee in the list (good)
FOR empno = 1 to listsize (ok)

NESTED CONSTRUCTS

The constructs can be embedded within each other, and this is made clear by use of indenting. Nested constructs should be clearly indented from their surrounding constructs.

Example

SET total to zero
REPEAT

IF Temperature > Freezing THEN
INCREMENT total
END IF

UNTIL Temperature < zero
Print total

In the above example, the IF construct is nested within the REPEAT construct, and therefore is indented.

INVOKING SUBPROCEDURES

Use the CALL keyword. For example:

CALL AvgAge with StudentAges
CALL Swap with CurrentItem and TargetItem
CALL Account.debit with CheckAmount
CALL getBalance RETURNING aBalance
CALL SquareRoot with orbitHeight RETURNING nominalOrbit

EXCEPTION HANDLING

BEGIN
statements
EXCEPTION
WHEN exception type
statements to handle exception
WHEN another exception type
statements to handle exception
END

### Sample Pseudocode

FOR X = 1 to 10
FOR Y = 1 to 10
IF gameBoard[X][Y] = 0
Do nothing
ELSE
CALL theCall(X, Y) (recursive method)
increment counter
END IF
END FOR
END FOR

“Better”

Set moveCount to 1
FOR each row on the board
FOR each column on the board
IF gameBoard position (row, column) is occupied THEN
INCREMENT moveCount
END IF
END FOR
END FOR

(Note: the logic is restructured to omit the “do nothing” clause)

“Not So Good”

FOR all the number at the back of the array
SET Temp equal the addition of each number
IF > 9 THEN
get the remainder of the number divided by 10 to that index
and carry the "1"
Decrement one
Do it again for numbers before the decimal

“Good Enough (not perfect)”

SET Carry to 0
FOR each DigitPosition in Number from least significant to most significant

COMPUTE Total as sum of FirstNum[DigitPosition] and SecondNum[DigitPosition] and Carry

IF Total > 10 THEN
SET Carry to 1
SUBTRACT 10 from Total
ELSE
SET Carry to 0
END IF

STORE Total in Result[DigitPosition]

END LOOP

IF Carry = 1 THEN
RAISE Overflow exception
END IF

“Pretty Good”  This example shows how pseudocode is written as comments in the source file. Note that the double slashes are indented.

public boolean moveRobot (Robot aRobot)
{
//IF robot has no obstacle in front THEN
// Call Move robot
// Add the move command to the command history
// RETURN true
//ELSE
// RETURN false without moving the robot
//END IF
}

Example Java Implementation

• source code statements are interleaved with pseudocode.
• comments that correspond exactly to source code are removed during coding.

public boolean moveRobot (Robot aRobot)
{
//IF robot has no obstacle in front THEN
if (aRobot.isFrontClear())
{
// Call Move robot
aRobot.move();
// Add the move command to the command history
return true;
}
else // don't move the robot
{
return false;
}//END IF
}

## Flowchart Mencari Bilangan Genap Kurang Dari 8 Yang Habis Dibagi 3

October 7th, 2010 No Comments »

Perbaikan Flowchart :

## Flowchart

October 7th, 2010 No Comments »

A flowchart is a type of diagram, that represents an algorithm or process, showing the steps as boxes of various kinds, and their order by connecting these with arrows. This diagrammatic representation can give a step-by-step solution to a given problem. Data is represented in these boxes, and arrows connecting them represent flow / direction of flow of data. Flowcharts are used in analyzing, designing, documenting or managing a process or program in various fields.[1]﻿

## History

The first structured method for documenting process flow, the “flow process chart”, was introduced by Frank Gilbreth to members of the American Society of Mechanical Engineers (ASME) in 1921 in the presentation “Process Charts—First Steps in Finding the One Best Way”. Gilbreth’s tools quickly found their way into industrial engineering curricula. In the early 1930s, an industrial engineer, Allan H. Mogensen began training business people in the use of some of the tools of industrial engineering at his Work Simplification Conferences in Lake Placid, New York.

A 1944 graduate of Mogensen’s class, Art Spinanger, took the tools back to Procter and Gamble where he developed their Deliberate Methods Change Program. Another 1944 graduate, Ben S. Graham, Director of Formcraft Engineering at Standard Register Corporation, adapted the flow process chart to information processing with his development of the multi-flow process chart to display multiple documents and their relationships.[2] In 1947, ASME adopted a symbol set derived from Gilbreth’s original work as the ASME Standard for Process Charts by Mishad, Ramsan & Raiaan.

Douglas Hartree explains that Herman Goldstine and John von Neumann developed the flow chart (originally, diagram) to plan computer programs.[3] His contemporary account is endorsed by IBM engineers[4] and by Goldstine’s personal recollections.[5] The original programming flow charts of Goldstine and von Neumann can be seen in their unpublished report, “Planning and coding of problems for an electronic computing instrument, Part II, Volume 1″ (1947), which is reproduced in von Neumann’s collected works.[6]

Flowcharts used to be a popular means for describing computer algorithms and are still used for this purpose.[7] Modern techniques such as UML activity diagrams can be considered to be extensions of the flowchart. In the 1970s the popularity of flowcharts as an own method decreased when interactive computer terminals and third-generation programming languages became the common tools of the trade, since algorithms can be expressed much more concisely and readably as source code in such a language. Often pseudo-code is used, which uses the common idioms of such languages without strictly adhering to the details of a particular one.

## Flowchart building blocks

### Examples

A simple flowchart for computing factorial N (10!)

A flowchart for computing factorial N (10!) where N! = (1*2*3*4*5*6*7*8*9*10), see image. This flowchart represents a “loop and a half” — a situation discussed in introductory programming textbooks that requires either a duplication of a component (to be both inside and outside the loop) or the component to be put inside a branch in the loop. (Note: Some textbooks recommend against this “loop and a half” since it is considered bad structure, instead a ‘priming read’ should be used and the loop should return back to the original question and not above it.[8])

###  Symbols

A typical flowchart from older computer science textbooks may have the following kinds of symbols:

Start and end symbols
Represented as circles, ovals or rounded rectangles, usually containing the word “Start” or “End”, or another phrase signaling the start or end of a process, such as “submit enquiry” or “receive product”.
Arrows
Showing what’s called “flow of control” in computer science. An arrow coming from one symbol and ending at another symbol represents that control passes to the symbol the arrow points to.
Processing steps
Represented as rectangles. Examples: “Add 1 to X”; “replace identified part”; “save changes” or similar.
Input/Output
Represented as a parallelogram. Examples: Get X from the user; display X.
Conditional or decision
Represented as a diamond (rhombus). These typically contain a Yes/No question or True/False test. This symbol is unique in that it has two arrows coming out of it, usually from the bottom point and right point, one corresponding to Yes or True, and one corresponding to No or False. The arrows should always be labeled.A decision is necessary in a flowchart. More than two arrows can be used, but this is normally a clear indicator that a complex decision is being taken, in which case it may need to be broken-down further, or replaced with the “pre-defined process” symbol.

A number of other symbols that have less universal currency, such as:

• A Document represented as a rectangle with a wavy base;
• A Manual input represented by parallelogram, with the top irregularly sloping up from left to right. An example would be to signify data-entry from a form;
• A Manual operation represented by a trapezoid with the longest parallel side at the top, to represent an operation or adjustment to process that can only be made manually.
• A Data File represented by a cylinder.

Flowcharts may contain other symbols, such as connectors, usually represented as circles, to represent converging paths in the flowchart. Circles will have more than one arrow coming into them but only one going out. Some flowcharts may just have an arrow point to another arrow instead. These are useful to represent an iterative process (what in Computer Science is called a loop). A loop may, for example, consist of a connector where control first enters, processing steps, a conditional with one arrow exiting the loop, and one going back to the connector. Off-page connectors are often used to signify a connection to a (part of another) process held on another sheet or screen. It is important to remember to keep these connections logical in order. All processes should flow from top to bottom and left to right.

## Types of flowchart

Example of a system flowchart.

Sterneckert (2003) suggested that flowcharts can be modelled from the perspective of different user groups (such as managers, system analysts and clerks) and that there are four general types:[9]

• Document flowcharts, showing controls over a document-flow through a system
• Data flowcharts, showing controls over a data flows in a system
• System flowcharts showing controls at a physical or resource level
• Program flowchart, showing the controls in a program within a system

Notice that every type of flowchart focuses on some kind of control, rather than on the particular flow itself.[9]

However there are several of these classifications. For example Andrew Veronis (1978) named three basic types of flowcharts: the system flowchart, the general flowchart, and the detailed flowchart.[10] That same year Marilyn Bohl (1978) stated “in practice, two kinds of flowcharts are used in solution planning: system flowcharts and program flowcharts…”.[11] More recently Mark A. Fryman (2001) stated that there are more differences: “Decision flowcharts, logic flowcharts, systems flowcharts, product flowcharts, and process flowcharts are just a few of the different types of flowcharts that are used in business and government”.[12]
In addition, many diagram techniques exist that are similar to flowcharts but carry a different name, such as UML activity diagrams.

## Software

A paper-and-pencil template for drawing flowcharts, late 1970s.

Any drawing program can be used to create flowchart diagrams, but these will have no underlying data model to share data with databases or other programs such as project management systems or spreadsheets. Some tools offer special support for flowchart drawing. Many software packages exist that can create flowcharts automatically, either directly from source code, or from a flowchart description language. On-line Web-based versions of such programs are available

Notes

1. ^ SEVOCAB: Software and Systems Engineering Vocabulary. Term: Flow chart. Retrieved 31 July 2008.
2. ^ Graham, Jr., Ben S. (10 June 1996). “People come first”. Keynote Address at Workflow Canada. http://www.worksimp.com/articles/keynoteworkflowcanada.htm.
3. ^ Hartree, Douglas (1949). Calculating Instruments and Machines. The University of Illinois Press. p. 112.
4. ^ Bashe, Charles (1986). IBM’s Early Computers. The MIT Press. p. 327.
5. ^ Goldstine, Herman (1972). The Computer from Pascal to Von Neumann. Princeton University Press. pp. 266–267. ISBN 0-691-08104-2.
6. ^ Taub, Abraham (1963). John von Neumann Collected Works. 5. Macmillan. pp. 80–151.
7. ^ Bohl, Rynn: “Tools for Structured and Object-Oriented Design”, Prentice Hall, 2007.
8. ^ Farrell, Joyce (2008). “Programming Logic and Design, 5th ed”. Comprehensive
9. ^ a b Alan B. Sterneckert (2003)Critical Incident Management. p. 126
10. ^ Andrew Veronis (1978) Microprocessors: Design and Applications‎. p. 111
11. ^ Marilyn Bohl (1978) A Guide for Programmers‎. p. 65.
12. ^ Mark A. Fryman (2001) Quality and Process Improvement‎. p. 169

## Ciri Algoritma

September 28th, 2010 No Comments »

Menurut Donald E. Knuth, algoritma mempunyai lima ciri penring :
1. Algoritma harus berhenti setelah mengerjakan sejumlah langkah terbatas.
2. Setiap langkah harus didefinisikan secara tepat dan tidak berarti dua.
3. Algoritma memiliki nol atau lebih masukan (input).
4. Algoritma mempunyai nol atau lebih keluaran (output).
5. Algoritma harus sangkil (efektif)

## Dasar Algoritma

September 25th, 2010 No Comments »

DEFINISI ALGORITMA
Terdapat beberapa definisi mengenai kata Algoritma :
1. Algoritma adalah urutan langkah-langkah logis penyelesaian masalah yang
disusun secara sistematis (Rinaldi Munir :2002).
2. Algoritma adalah urutan logis pengambilan keputusan untuk pemecahan
masalah (KBBI :1988).
3. Algoritma adalah suatu himpunan hingga dari instruksi-instruksi yang secara
jelas memperinci langkah-langkah proses pelaksanaan, dalam pemecahan
suatu masalah tertentu, atau suatu kelas masalah tertentu, dengan dituntut
pula bahwa himpunan instruksi tersebut dapat dilaksanakan secara mekanik