Code Algo 2 (Modul 2 = Input Proses Output)

Modul 2
Modul 2

Silahkan -> Free DownLoad…!!!

the mr.fox guard

Contact : RAHMADI, SE, SKom

Phone : 0511 7514143

Address : Jl.Sekumpul Gang Puji Rahayu RT.12 RW.06 Martapura-Kalimantan Selatan -Indonesia

Email ke Boutique Software Programming

Advertisements

Code Algo 2 (Modul 1 = Input Output)

Modul 1
Modul 1

Silahkan -> Free DownLoad…!!!

the mr.fox guard

Contact : RAHMADI, SE, SKom

Phone : 0511 7514143

Address : Jl.Sekumpul Gang Puji Rahayu RT.12 RW.06 Martapura-Kalimantan Selatan -Indonesia

Email ke Boutique Software Programming

Link E Book Delphi

Link E Book Delphi

Link Tutorial Delphi7.0…!

Link Delphi dengan MySQL…!

Link Pengenalan Ms Access…!

Link Koneksi Delphi ke Ms Access…!

Link Komponen Tabel…!

Link Komponen Query…!

Link Komponen Representasi Data…!

Link Komponen Report…!

Link Membuat Form Uniik Dengan Dellphii 7..0…!

Silahkan -> Free DownLoad…!!!

the mr.fox guard

Contact : RAHMADI, SE, SKom

Phone : 0511 7514143

Address : Jl.Sekumpul Gang Puji Rahayu RT.12 RW.06 Martapura-Kalimantan Selatan -Indonesia

Email ke Boutique Software Programming

Link E Book Pascal

Link E Book Pascal

Link Bahasa Pemprograman PASCAL…!

Link Struktur Bahasa PASCAL…!

Link STRUKTUR PASCAL…!

Link Mengapa Pascal?…!

Link Pemrograman Pascal:Subprogram…!

Silahkan -> Free DownLoad…!!!

the mr.fox guard

Contact : RAHMADI, SE, SKom

Phone : 0511 7514143

Address : Jl.Sekumpul Gang Puji Rahayu RT.12 RW.06 Martapura-Kalimantan Selatan -Indonesia

Email ke Boutique Software Programming

Logical – IF – CASE OF

1: Program Tutorial2_if;
2: var pilih: Integer;
3: Begin
4:   write('Pilih 1 atau 2'); readln(pilih);
5:   if pilih=1 then write('Anda memilih 1')
6:   elseif pilih=2 then write('Pilihan anda 2')
7:   else write('Anda memilih yang lain');
8: End.

 1: Program Tutorial2_case;
 2: var pilih: char;
 3: Begin
 4:   write('Pilih 1 atau 2'); readln(pilih);
 5:   case pilih of
 6:     '1': write('Anda memilih 1');
 7:     '2': write('Pilihan anda 2');
 8:   else write('Anda memilih yang lain');
 9:   end;
10: End.

Program CaseOf_Or;
Uses crt;
Var
Hargaperkg:integer;
Kualitas:char;
Begin
Clrscr;
Write(‘ Massukkan Kualitas Buah [A/B/C] : ‘); readln(kualitas);
Case kualitas of
‘A’,’a’: hargaperkg:=1000;
‘B’,’b’: hargaperkg:=750;
‘C’,’c’: hargaperkg:=500;
Else
Hargaperkg:=0;
End;
Writeln(‘ Harga Per Kg : Rp.’,hargaperkg);
readln;
End.

Structure Case...Of;

In the 1970s, programming language designers were looking for simpler ways to write statements that were previously involved expressions. Since the programmers made more errors on complex statements, it seemed reasonable to attempt to distill the BLOCK-IF into a more concise representation. In PASCAL, this representation is called the CASE statement. Instead of relational operators, the CASE statement simply specifies possible values for a variable, together with statements to be executed if that variable has a given value. For example, consider the following CASE statement (written in pseudocode) for a academic grade evaluation:

CASE OF grade:

‘A’: WRITELN(‘Excellent work!’);

‘B’: WRITELN(‘You did well…’);

‘C’: WRITELN(‘Average performance.’);

‘D’: WRITELN(‘Needs some improvement…’);

‘E’: WRITELN(‘Trouble ahead!’);

END-CASE

Certainly this simple instance of the CASE statement is easier to read than the corresponding BLOCK-IF statement:

IF grade == ‘A’ THEN WRITELN(‘Excellent work!’)

ELSEIF grade == ‘B’ THEN WRITELN(‘You did well…’)

ELSEIF grade == ‘C’ THEN WRITELN(‘Average performance.’)

ELSEIF grade == ‘D’ THEN WRITELN(‘Needs some improvement…’)

ELSEIF grade == ‘E’ THEN WRITELN(‘Trouble ahead!’);

ENDIF

The problem with CASE statements occurs not when the statement blocks are small, or when there are a few alternatives. Rather, the CASE statement begins to defeat its design goal of conciseness and readability when the blocks of statements become large or when there are many alternatives. In such expressions, a given CASE statement may span several pages or more. When you are trying to debug such statements, it becomes very difficult to remember where you are in the statement, and one tends to feel lost. As a result, we prefer to use only IF or BLOCK-IF statements for decision structures.

(http://www.cise.ufl.edu)


The Simple Case Statement

So far, you have learned how to use an ‘if statement’. But in some cases the ‘case statement‘ is preferred to the if statement because it reduces some unnecessary code but the same meaning is retained. The case statement is very similar to the if statement, except in that the it does not accept literal conditional expressions (i.e.: strings) but surprisingly enough, it allows single character conditional expressions. Here is how it works:

Case {variable of type: integer or character ONLY} of

{input statement- within inverted commas if of type char} : {code..}

{input statement- within inverted commas if of type char} : {code..}

End; {End Case}

http://pascalprogramming.byethost15.com

Looping

1: Program Tutorial3_for;
2: var i: Integer;
3: Begin
4:   For i:=1 to 5 do
5:     writeln('ini yang ke ', i);
6: End.

 1: Program Tutorial3_while;
 2: var i: Integer;
 3: Begin
 4:   i:=1;
 5:   while i < 5 do
 6:   begin
 7:     writeln('ini yang ke ', i);
 8:     i:=i+1;
 9:   end;
10: End.

1: Program Tutorial3_repeat;
2: var pilih: char;
3: Begin
4:   i:=1;
5:   repeat
6:     writeln('ini yang ke ',i);
7:     i:=i+1;
8:   until i<0;
9: End.

Procedure

USES CRT;
CONST
     max = 10;
     garis = '----------------------------------------------------------------';
 TYPE
     rec_data = record;
     nip : string[25];
     nama : string[25];
     gol : string[5];
     gapok : real;
     tunj : real;
     gator : real; 
     pot : real;
     gaber : real;
 END;
 VAR
     rpeg : rec_data;
     peg : file of rec_data;
     lagi : char;

 PROCEDURE entrydata;
   BEGIN
     ASSIGN (peg,'c:\peg.dat');
     REWRITE (peg);
     CLRSCR;
       BEGIN
          CLRSCR;
          WRITE ('nip :');READLN(rpeg.nip);
          IF rpeg.nip=" THEN HALT;
          WRITE ('nama :');READLN(rpeg.nama);
          WRITE ('golongan :');READLN(rpeg.gol);
       END;
   END; 
   {Akhir procedure entrydata} 

 PROCEDURE prosesdata;
   BEGIN
     IF rpeg.gol = 'I/a' THEN rpeg.gapok :=250000;
     IF rpeg.gol = 'I/b' THEN rpeg.gapok :=300000;
     IF rpeg.gol = 'II/a' THEN rpeg.gapok :=350000;
     IF rpeg.gol = 'II/b' THEN rpeg.gapok :=400000;
     IF rpeg.gol = 'III/a' THEN rpeg.gapok :=450000; 
     IF rpeg.gol = 'III/b' THEN rpeg.gapok :=500000;
     rpeg.tunj :=(0.1)*rpeg.gapok;
     rpeg.gator :=rpeg.gapok*rpeg.tunj;
     rpeg.pot :=(0.02)*rpeg.gator;
     rpeg.gaber :=rpeg.gator-rpeg.pot;
   END;
   {Akhir procedure prosesdata}

 PROCEDURE tampildata; 
   BEGIN
     CLRSCR;
     GOTOXY (1,1);WRITE (' daftar gaji pegawai ');
     GOTOXY (1,2);WRITE (garis);
     GOTOXY (1,3);WRITE (' nip nama gol gapok tunj
gator pot gaber');
     GOTOXY (1,4);WRITE (garis);
     BEGIN
          GOTOXY (2,5) ;WRITELN (rpeg.nip);
          GOTOXY (9,5) ;WRITELN (rpeg.nama);
          GOTOXY (18,5);WRITELN (rpeg.gol);
          GOTOXY (24,5);WRITE (rpeg.gapok:10:0);
          GOTOXY (33,5);WRITE (rpeg.tunj:10:0);
          GOTOXY (44,5);WRITE (rpeg.gator:10:0);
          GOTOXY (54,5);WRITE (rpeg.pot:10:0);
          GOTOXY (68,5);WRITE (rpeg.gaber:10:0);
     END;
   END;
   {Akhir procedure tampildata}

 BEGIN {Program utama}
     CLRSCR;
     REPEAT
          entrydata;
          prosesdata;
          tampildata;
          WRITELN;
          WRITE (' coba lagi : [Y/T]:');
          REPEAT
             lagi:=UPCASE (READKEY);
          UNTIL lagi IN ['Y','T'];
     UNTIL lagi ='T';
     CLOSE (peg);
 END.

Function

{ buat fungsi yang menentukan nilai terbesar }
{ dari 2 buah bilangan }

  USES CRT;
  VAR
	  A : interger;
	  B : interger;
	  C : interger;
  FUNCTION nilaiterbesar (na,nb:interger):interger;
	  BEGIN
		   IF na>nb THEN
			   nilaiterbesar:=na
		   ELSE
			   nilai terbear:=nb;
	  END;
  BEGIN
	  CLRSCR;
	  WRITE ('Masukan nilai A:');
	  READLN (A);
	  WRITE ('Masukan nilai B:');
	  READLN (B);
	  C:=nilaiterbesar (A,B);
	  WRITELN ('NILAI TERBESAR = ',C );
  END.

Structure Pascal – Struktur Program PASCAL

Bahasa Pascal memiliki struktur sbb:

PROGRAM NamaProgram (FileList);
CONST
(* pendeklarasian konstanta *)
TYPE
(* pendeklarasian tipe *)
VAR
(* pendeklarasian variabel *)
(* pendefinisian subprogram-procedure atau function *)

BEGIN
(* batang tubuh/ main body *)
END.

Susunan/ urutan struktur di atas harus dipenuhi. Meskipun demikian, kita dapat menghilangkan beberapa bagian struktur apabila tidak diperlukan.

Untuk memberikan komentar dalam PASCAL, digunakan perintah { komentar } atau (* komentar
*).