- Uses Crt;
- Const
- JumlahSiswa = 3;
- Type Nilai = Record
- Nim : String;
- Nama: String;
- Tugas : Real;
- UTS : Real;
- UAS : Real;
- Na : Real;
- Grade : Char;
- End;
- Var
- Mhs : Array[1..JumlahSiswa] of Nilai;
- I : Integer;
- Begin
- Clrscr;
- For I := 1 To JumlahSiswa Do
- Begin
- With Mhs[i] Do
- Begin
- Writeln('Mahasiswa ke : ',i:2);
- Write('Nim : ');Readln(Nim);
- Write('Nama : ');Readln(Nama);
- Write('Tugas : ');Readln(Tugas);
- Write('UTS : ');Readln(Uts);
- Write('UAS : ');Readln(Uas);
- End;
- End;
- For I := 1 To JumlahSiswa Do
- Begin
- With Mhs[i] Do
- Begin
- Na := (Tugas + Uts + Uas) / 3;
- If (Na >= 80) Then Grade := 'A' Else
- If (Na < 80) and (Na>=70) Then Grade := 'B' Else
- If (Na < 70) and (Na>=60) Then Grade := 'C' Else
- If (Na < 60) and (Na>=50) Then Grade := 'D' Else
- Grade :='E';
- End;
- End;
- Writeln('----------------------------------------------------------');
- Writeln(' NO NIM NAMA TUGAS UTS UAS NA GRADE ');
- Writeln('----------------------------------------------------------');
- For I := 1 To JumlahSiswa Do
- Begin
- With Mhs[i] Do
- Begin
- Writeln(i:3,Nim:10,Nama:10,Tugas:7:2,Uts:7:2,
- Uas:7:2,Na:7:2,Grade:5);
- End;
- End;
- Readln;
- End.
Jika program ini dijalankan, maka akan mendapatkan hasil output yang sama seperti dengan tanpa menggunakan statement With
Tidak ada komentar:
Posting Komentar