Array Of Record

Berikut ini merupakan contoh program pascal untuk mengetahui grade dari sebuah nilai

uses crt;
type mhs = record
        nama,nim,grade    :string;
        nilai             :byte;
end;
var data        : array [1..100] of mhs;

    pilih       : char;
    i,n         : byte;




procedure input;
begin
clrscr;
     writeln('       Input Data Mahasiswa');
     writeln('      ----------------------'); writeln;
     write('Masukan Jumlah Mahasiswa : '); readln(n);
     clrscr;

     for i:= 1 to n do
     begin
       with data[i] do
       begin
       writeln('Data ke-',i);
       writeln('-------------------------');
       write('Nama      : '); readln(nama);
       write('NIM       : '); readln(nim);
       write('Nilai     : '); readln(nilai);
       writeln;
       end
     end;
end;

function grade:string;
begin

     for i:= 1 to n do
     begin
       with data[i] do
       begin
        if nilai<50 then grade:='E';
        if nilai>=50 then grade:='D';
        if nilai>=60 then grade:='C';
        if nilai>=65 then grade:='C+';
        if nilai>=70 then grade:='B';
        if nilai>=75 then grade:='B+'else
        if nilai>=80 then grade:='A';
       end
     end;
end;

procedure output;
        begin
            clrscr;
            grade;
            writeln('|====================================================|');
            writeln('|            Laporan Data Nilai Mahasiswa            |');
            Writeln('|===========|=====================|========|=========|');
            writeln('|    NIM              Nama           Nilai    Grade  |');
            Writeln('|===========|=====================|========|=========|');
            For i:=1 To n Do
            Begin
            with data[i] do
            begin
            gotoxy(1,5+i);writeln('|');
            gotoxy(13,5+i);writeln('|');
            gotoxy(35,5+i);writeln('|');
            gotoxy(44,5+i);writeln('|');
            gotoxy(54,5+i);writeln('|');
            gotoxy(3,5+i);Writeln(nim);
            gotoxy(15,5+i);writeln(nama);
            gotoxy(39,5+i);writeln(nilai);
            gotoxy(48,5+i);writeln(grade);
            end;
            end;
            Writeln('|===========|=====================|========|=========|');
            readln;
            end;

BEGIN
repeat
clrscr;
        writeln('            Menu Utama');
        writeln('         ---------------');
        writeln('         1.Masukkan Data');
        writeln('         2.Lihat Data');
        writeln('         3.Keluar');
        writeln;
        write('         Masukkan Pilihan : ');readln(pilih);

        case pilih of
        '1':input;
        '2':output;
        '3':exit;
        end;
        until pilih='3';
END.

Output Program

Array Of Record Array Of Record Reviewed by Ardiansyahsw on 05.43 Rating: 5

Tidak ada komentar:

Events

Diberdayakan oleh Blogger.