Langkah-langkah membuat program sortir data mahasiswa menurut kelas dengan menggunakan Turbo Pascal for Windows V1.5
Program Sorting;
Uses CRT;
Const
Garis='---------------------------------------------------';
var
Kelas : Array [1..100] of string [6];
NPM : Array [1..100] of string [10];
Nama : Array [1..100] of string [20];
M,T : String;
A,N,BRS,INPUT,LETAK_M,Pilih : Integer;
Label Menu;
Label Exit;
Begin
Clrscr;
Write ('Isi Berapa Banyak Data : ');
Readln(A);
For N := 1 to A do
Begin
Clrscr;
GOTOXY (20,6); Write ('Data ke-',N:2);
GOTOXY (20,8); Write ('Nama :'); Readln (Nama[N]);
GOTOXY (20,9); Write ('NPM :'); Readln (NPM[N]);
GOTOXY (20,10); Write ('Kelas :'); Readln (Kelas[N]);
End;
Menu :
Clrscr;
Writeln ('Pilihan :');
Writeln ('1. Sort By Class');
Writeln ('2. Exit');
Write ('Pilihanya ? : '); Readln (Pilih);
Case Pilih OF
1:FOR INPUT := 1 TO A DO
Begin
M := KELAS [INPUT];
For N := INPUT TO A DO
Begin
IF (Kelas [N] <=M) Then
Begin
M := Kelas [N];
LETAK_M := N;
END;
END;
T := Kelas [INPUT];
Kelas [INPUT] := Kelas [LETAK_M];
Kelas [Letak_M] := T;
T := NPM [INPUT];
NPM [INPUT] := NPM [LETAK_M];
NPM [LETAK_M] := T;
T := Nama [INPUT];
Nama [INPUT] := Nama [LETAK_M];
Nama [Letak_M]:= T;
END;
2:GOTO EXIT;
END;
GOTOXY (7,5); Write (Garis);
GOTOXY (7,6); Write ('NO');
GOTOXY (12,6); Write ('NPM');
GOTOXY (22,6); Write ('NAMA');
GOTOXY (43,6); Write ('KELAS');
GOTOXY (7,7); Write (GARIS);
BRS := 8;
FOR N := 1 TO A DO
Begin
GOTOXY (7,BRS) ; Writeln (N:2);
GOTOXY (12,BRS) ; Writeln (NPM[N]);
GOTOXY (22,BRS) ; Writeln (Nama [N]);
GOTOXY (43,BRS) ; Writeln (Kelas [N]);
BRS := BRS + 1;
END;
GOTOXY (7,BRS + 1 ); Writeln (GARIS);
Readln;
GOTO MENU;
EXIT:
END.
OUTPUT:
Tidak ada komentar:
Posting Komentar