PROGRAM pemakaian_Array_Untuk_10_data_dengan_menggunakan_For;
USES CRT;
CONSt
garis='------------------------------------------------------';
VAR
nil1,nil2 : ARRAY [1..10] OF 0..100; {Array dgn Type subjangkauan}
npm : ARRAY [1..10] OF STRING[8];
nama : ARRAY [1..10] OF STRING[15];
n,i,bar : INTEGER;
jum : REAL;
t1: CHAR;
BEGIN
CLRSCR;
{ pemasukan data dalam array }
WRITE('MAU ISI BERAPA DATA :');
READLN(N);
FOR i:= 1 TO n DO
BEGIN
CLRSCR;
GOTOXY(30,4+1); WRITE('DATA KE-:',i:2);
GOTOXY(10,5+i); WRITE('NPM :'); READLN(NPM[i]);
GOTOXY(10,6+i); WRITE('NAMA :'); READLN(NAMA[i]);
GOTOXY(10,7+i); WRITE('NILAI 1 :'); READLN(NIL1[i]);
GOTOXY(10,8+i); WRITE('NILAI 2 :'); READLN(NIL2[i]);
END;
{ proses data dalam array }
CLRSCR;
GOTOXY(5,4); WRITE(GARIS);
GOTOXY(5,5); WRITE('NO');
GOTOXY(9,5); WRITE('NPM');
GOTOXY(18,5); WRITE('NAMA');
GOTOXY(34,5); WRITE('NIL.1');
GOTOXY(41,5); WRITE('NIL.2');
GOTOXY(47,5); WRITE('RATA');
GOTOXY(54,5); WRITE('ABJAD');
GOTOXY(5,6); WRITE(GARIS);
{ proses Cetak isi array dan seleksi kondisi }
bar:=7;
FOR i:= 1 TO n DO
BEGIN
jum:=(nil1[i]+nil2[i])/2;
IF jum>=90 THEN t1:='A'
ELSE
IF jum>80 THEN t1:='B'
ELSE
IF jum>60 then t1:='C'
ELSE
IF jum>50 THEN t1:='D'
ELSE
t1:='E';
{ cetak hasil yang disimpan di array dan hasil }
{ penyeleksian kondisi }
GOTOXY(5,bar); WRITELN(i:2);
GOTOXY(9,bar); WRITELN(NPM[i]);
GOTOXY(18,bar); WRITELN(NAMA[i]);
GOTOXY(34,bar); WRITELN(NIL1[i]:4);
GOTOXY(41,bar); WRITELN(NIL2[i]:4);
GOTOXY(47,bar); WRITELN(jum:5:1);
GOTOXY(54,bar); WRITELN(t1);
bar:=bar+1;
END;
GOTOXY(5,bar+1);WRITELN(garis);
READLN;
END.
http://Layla-innocent.blogspot.com
Tidak ada komentar:
Posting Komentar