Pascal hitung nilai rata-rata

program hitung_nilai;

uses crt;

var
nilai:array[1..10] of integer;
nilai2:array[1..10] of integer;
nilai3:array[1..10] of integer;
nama:array[1..10] of string[50];
I,jum_mhs:integer;
rata:array[1..10] of double;
total:array[1..10] of integer;
huruf:array[1..10] of string[10];
begin
 clrscr;
 writeln('Program Penghitung Nilai Rata-rata mahasiswa');
 writeln('============================================');
 writeln;
 writeln;
 write('Masukkan jumlah mahasiswa : ');
 readln(jum_mhs);
 writeln('==================================================');
 writeln('| No | Nama | Nilai 1 | Nilai 2 | Nilai 3 |'); 


 for I:=1 to jum_mhs do
 begin
 gotoxy(1,I+7);write('|');
 gotoxy(3,I+7);write(I);
 gotoxy(6,I+7);write('|');
 gotoxy(8,I+7);readln(nama[I]);
 gotoxy(20,I+7);write('|');
 gotoxy(22,I+7);readln(nilai[I]);
 gotoxy(30,I+7);write('|');
 gotoxy(32,I+7);readln(nilai2[I]);
 gotoxy(40,I+7);write('|');
 gotoxy(42,I+7);readln(nilai3[I]);
 gotoxy(50,I+7);write('|');
 total[I]:=nilai[I]+nilai2[I]+nilai3[I];
 rata[I]:=total[I]/3;

 if (rata[I]>=80) then
 huruf[I]:='A'
 else if(rata[I]>=70) then
 huruf[I]:='B'
 else if(rata[I]>=60) then
 huruf[I]:='C'
 else if(rata[I]>=50) then
 huruf[I]:='D'
 else if(rata[I]<50) then
 huruf[I]:='E'


 end;
 writeln;
 writeln;
 writeln('Press any key to continue . . . ');
 readkey;

 clrscr;
 writeln('Program Penghitung Nilai Rata-rata mahasiswa');
 writeln('============================================');
 writeln;
 writeln;
 writeln('Jumlah Mahasiswa : ',jum_mhs);
 writeln('==========================================================================');
 writeln('| No | Nama | Nilai 1 | Nilai 2 | Nilai 3 | Rata | Total | Huruf |'); 


 for I:=1 to jum_mhs do
 begin
 gotoxy(1,I+7);write('|');
 gotoxy(3,I+7);write(I);
 gotoxy(6,I+7);write('|');
 gotoxy(8,I+7);write(nama[I]);
 gotoxy(20,I+7);write('|');
 gotoxy(22,I+7);write(nilai[I]);
 gotoxy(30,I+7);write('|');
 gotoxy(32,I+7);write(nilai2[I]);
 gotoxy(40,I+7);write('|');
 gotoxy(42,I+7);write(nilai3[I]);
 gotoxy(50,I+7);write('|');
 gotoxy(52,I+7);write(rata[I]:5:2);
 gotoxy(58,I+7);write('|');
 gotoxy(60,I+7);write(total[I]);
 gotoxy(66,I+7);write('|');
 gotoxy(68,I+7);write(huruf[I]);
 gotoxy(74,I+7);write('|');


 end;
 writeln;
 writeln('==========================================================================');


 readkey;






end.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *