Test


Daftar Blog Saya

Recent Posts

Páginas vistas en total

Diberdayakan oleh Blogger.

Pengikut

MENGHITUNG NILAI MAHASISWA DENGAN PASCAL

MENGHITUNG NILAI MAHASISWA DENGAN PASCAL


program nilai_mahasiswa;
uses crt;
type mahasiswa = record
Nama   : string[18];
Nim      : string[10];
ket        : string;
N          : array[1..7] of real;
end;
var
filemahasiswa          : file of mahasiswa;
recordmahasiswa    : mahasiswa;
lagi                              : char;
jumlahrecord,i         : integer;
pilih                           : integer;
ketemu                      : boolean;
namacari                  : string[18];
nomorcari                : string[18];
procedure menambahData;
begin
assign(filemahasiswa,’Latihan2.txt’);
rewrite(filemahasiswa);
lagi :=’Y';
while upcase (lagi)=’Y’ do
begin
with recordmahasiswa do
begin
clrscr;
textcolor(green);
gotoXY(34,1);write(‘MEMASUKKAN DATA’);
gotoXY(27,2);write(‘TEKAN ENTER SETELAH MENGISI DATA’);
gotoXY(6,3);write(‘========================================================================’);
gotoXY(6,5);write(‘NAMA                                                 :’);
gotoXY(6,7);write(‘NIM                                                     :’);
gotoXY(6,9);write(‘NILAI TATAP MUKA                      :’);
gotoXY(6,11);write(‘NILAI TUGAS MANDIRI              :’);
gotoXY(6,13);write(‘NILAI PRAKTEK                            :’);
gotoXY(6,15);write(‘NILAI TUGAS TERSTRUKTUR :’);
gotoXY(6,17);write(‘NILAI MID                                      :’);
gotoXY(6,19);write(‘NILAI SEMESTER                        :’);
gotoXY(33,5);Readln(nama);
gotoXY(33,7);Readln(nim);
gotoXY(33,9);Readln(n[1]);
gotoXY(33,11);Readln(n[2]);
gotoXY(33,13);Readln(n[3]);
gotoXY(33,15);Readln(n[4]);
gotoXY(33,17);Readln(n[5]);
gotoXY(33,19);Readln(n[6]);
n[7] :=(n[1]*2+n[2]*2+n[3]*2+n[4]*2+n[5]*2+n[6]*2)/12;
if (n[7]>=0) and (n[7]<1)then ket :=’E T lulus’
else if (n[7]>=1) and (n[7]<1.5)then ket :=’D T lulus’
else if (n[7]>=1.5) and (n[7]<2.5)then ket :=’C lulus’
else if (n[7]>=2.5) and (n[7]<3.5)then ket :=’B lulus’
else if (n[7]>=3.5) and (n[7]<=4)then ket :=’A lulus’;
end;
write(filemahasiswa,recordmahasiswa);
gotoXY(6,21);Write(‘masukkan data lagi (y/t)?’);readln(lagi);
end;
close (filemahasiswa);
end;
procedure menampilkanData;
begin
clrscr;
textcolor(green);
assign(filemahasiswa,’latihan2.txt’);
reset(filemahasiswa);
jumlahrecord :=filesize(filemahasiswa);
gotoXY(28,1);Write(‘NILAI AKHIR MAHASISWA’);
gotoXY(29,2);Write(‘  FAKULTAS TEKNIK’);
writeln;
writeln(‘================================================================================’);
writeln(‘|’,'NO’:2,’|',’NIM’:10,’|',’NAMA’:18,’|',’TM’:4,’|',’TMD’:4,’|',’PRK’:4,’|',’TT’:4,’|',
‘MID’:4,’|',’SEM’:4,’|',’NA’:4,’|',’KLA’);
write(‘——————————————————————————–’);
for i:= 1 to jumlahrecord do
begin
textcolor(white);
read(filemahasiswa,recordmahasiswa);
with recordmahasiswa do
write(‘|’,i:2,’|',nim:10,’|',nama:18,’|',n[1]:2:2,’|',n[2]:2:2,’|',n[3]:2:2,’|',n[4]:2:2,’|',n[5]:2:2,’|',
n[6]:2:2,’|',n[7]:2:2,’|',ket);
WRITELN;
textcolor(green);
write(‘——————————————————————————–’);
end;
close(filemahasiswa);
end;
procedure carimahasiswa;
begin
assign(filemahasiswa,’latihan2.txt’);
reset(filemahasiswa);
jumlahrecord :=filesize(filemahasiswa);
lagi:=’Y';
while upcase(lagi)=’Y’ do
begin
ketemu := false;
clrscr;
gotoXY(6,2);write(‘Nama  mahasiswa dicari?’);readln(nomorcari);
writeln;
for i := 1 to jumlahrecord do
begin
seek(filemahasiswa,i-1);
read(filemahasiswa,recordmahasiswa);
if recordmahasiswa.nama=nomorcari then
begin
ketemu := true;
gotoXY(6,4);write(‘Nama mahasiswa :’,recordmahasiswa.nama);
gotoXY(6,6);write(‘Klasifikasi    :’,recordmahasiswa.ket);
end;
end;
if not ketemu then
write(‘     Tidak ada nama mahasiswa ini!!!’);
gotoXY(6,10);write(‘Ada lagi yang akan dicari ?’);readln(lagi);
end;
close(filemahasiswa)
end;
procedure koreksidata;
begin
assign(filemahasiswa,’latihan2.txt’);
reset(filemahasiswa);
jumlahrecord := filesize(filemahasiswa);
lagi:=’Y';
while upcase (lagi)=’Y’ do
begin
ketemu := false;
clrscr;
gotoXY(6,2);write(‘Nama mahasiswa di cari ?’);readln(namacari);
writeln;
for i := 1 to jumlahrecord do
begin
seek(filemahasiswa,i-1);
read(filemahasiswa,recordmahasiswa);
if recordmahasiswa.nama = namacari then
begin
with recordmahasiswa do
begin
ketemu := true;
gotoXY(6,5);write(‘NAMA                                                :’,nama);
gotoXY(6,6);write(‘koreksinya                                        :’);
gotoXY(6,7);write(‘NIM                                                    :’,nim);
gotoXY(6,8);write(‘koreksinya                                        :’);
gotoXY(6,9);write(‘NILAI TATAP MUKA                     :’,n[1]:2:2);
gotoXY(6,10);write(‘koreksinya                                       :’);
gotoXY(6,11);write(‘NILAI TUGAS MANDIRI             :’,n[2]:2:2);
gotoXY(6,12);write(‘koreksinya                                       :’);
gotoXY(6,13);write(‘NILAI PRAKTEK                           :’,n[3]:2:2);
gotoXY(6,14);write(‘koreksinya                                       :’);
gotoXY(6,15);write(‘NILAI TUGAS TERSTRUKTUR :’,n[4]:2:2);
gotoXY(6,16);write(‘koreksinya                                       :’);
gotoXY(6,17);write(‘NILAI MID                                      :’,n[5]:2:2);
gotoXY(6,18);write(‘koreksinya                                       :’);
gotoXY(6,19);write(‘NILAI SEMESTER                        :’,n[6]:2:2);
gotoXY(6,20);write(‘koreksinya                                      :’);
gotoXY(31,6);Readln(nama);
gotoXY(31,8);Readln(nim);
gotoXY(31,10);Readln(n[1]);
gotoXY(31,12);Readln(n[2]);
gotoXY(31,14);Readln(n[3]);
gotoXY(31,16);Readln(n[4]);
gotoXY(31,18);Readln(n[5]);
gotoXY(31,20);Readln(n[6]);
writeln;
n[7] :=(n[1]*2+n[2]*2+n[3]*2+n[4]*2+n[5]*2+n[6]*2)/12;
if (n[7]>=0) and (n[7]<1)then ket :=’E T lulus’
else if (n[7]>=1) and (n[7]<1.5)then ket :=’D T lulus’
else if (n[7]>=1.5) and (n[7]<2.5)then ket :=’C lulus’
else if (n[7]>=2.5) and (n[7]<3.5)then ket :=’B lulus’
else if (n[7]>=3.5) and (n[7]<=4)then ket :=’A lulus’;
end;
end;
seek(filemahasiswa,i-1);
write(filemahasiswa,recordmahasiswa);
end;
if not ketemu then
write(‘     tidak ada nama mahasiswa  ini !!! ‘);
gotoXY(6,24);write(‘ada lagi yang di cari?  :’);readln(lagi);
end;
close (filemahasiswa);
end;
begin
while true do
begin
Clrscr;
textbackground(red);
textcolor(yellow);
gotoXY(25,2);Write(‘<<<<<<<MENU>>>>>>>’);
textcolor(green);
gotoXY(25,4);Write(‘pilih 1 untuk mengisi data’);
gotoXY(25,5);Write(‘pilih 2 untuk menampilkan data’);
gotoXY(25,6);Write(‘pilih 3 untuk cari mahasiswa’);
gotoXY(25,7);Write(‘pilih 4 untuk koreksi data’);
gotoXY(25,8);Write(‘pilih 5 untuk keluar(EXIT)’);
pilih :=0;
BEGIN
gotoXY(25,10);Write(‘MENU YANG ANDA PILIH?’);READLN(PILIH);
if (pilih<1) or (pilih>3) then
gotoXY(6,12);Write(‘MENU INI TIDAK TERSEDIA’);
end;
case pilih of
1 : menambahData;
2 : BEGIN
menampilkandata;
writeln;
write(‘TEKAN ENTER UNTUK KEMBALI KE MENU’);
readln;
end;
3 : carimahasiswa;
4 : koreksidata;
5 : exit;
end;
end;
end.
perhatian :
koding di atas bisa saja terbongkar susunannya kalau di salin ke pascal jadi anda perlu mengaturnya kembali.
Share on Google Plus

About Gede Eri

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 komentar:

Posting Komentar