Last active
September 28, 2022 08:25
-
-
Save anonemae/5af526cd516c57beadf07ef8001bb565 to your computer and use it in GitHub Desktop.
Tugas Praktikum Struktur Data BAB 2 latihan 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| program bab_2_latihan_1; | |
| uses crt; | |
| type | |
| rec_mhs = | |
| record | |
| nama, npm: string; | |
| tugas, uts, uas: real; | |
| end; | |
| var | |
| bnyk_data, i : integer; | |
| mahasiswa: array [1..5] of rec_mhs; | |
| procedure printGrade(na : real); | |
| begin | |
| if (round(na) >= 80) then | |
| write('A') | |
| else if (round(na) >= 70) then | |
| write('B') | |
| else if (round(na) >= 60) then | |
| write('C') | |
| else if (round(na) >= 50) then | |
| write('D') | |
| else if (round(na) < 50) then | |
| write('E') | |
| else | |
| write('undefined'); | |
| end; | |
| begin | |
| clrscr; | |
| write('Berapa jumlah mahasiswa : ');readln(bnyk_data); | |
| if bnyk_data > 5 then | |
| begin | |
| writeln('Data tidak boleh lebih dari 5'); | |
| end | |
| else | |
| begin | |
| for i := 1 to bnyk_data do | |
| begin | |
| writeln; | |
| writeln('Mahasiswa ke : ', i); | |
| write('NPM : ');readln(mahasiswa[i].npm); | |
| write('NAMA : ');readln(mahasiswa[i].nama); | |
| write('TUGAS : ');readln(mahasiswa[i].tugas); | |
| write('UTS : ');readln(mahasiswa[i].uts); | |
| write('UAS : ');readln(mahasiswa[i].uas); | |
| end; | |
| writeln; | |
| writeln('-----------------------------------------------------------------'); | |
| writeln('No NPM NAMA TUGAS UTS UAS NA GRADE'); | |
| writeln('-----------------------------------------------------------------'); | |
| for i := 1 to bnyk_data do | |
| begin | |
| write(i, ' '); | |
| write(mahasiswa[i].npm, ' '); | |
| write(mahasiswa[i].nama, ' '); | |
| write(mahasiswa[i].tugas:0:2, ' '); | |
| write(mahasiswa[i].uts:0:2, ' '); | |
| write(mahasiswa[i].uas:0:2, ' '); | |
| write(((mahasiswa[i].tugas+mahasiswa[i].uts+mahasiswa[i].uas)/3):0:2, ' '); | |
| printGrade((mahasiswa[i].tugas+mahasiswa[i].uts+mahasiswa[i].uas)/3); | |
| writeln; | |
| end; | |
| end; | |
| readln; | |
| end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment