C++
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#define DATAMAX 50
typedef int bulat;
struct nilaiMHS
{ char npm[11];
bulat hadir, tugas, quiz, nts, nas;
};
void main()
{ nilaiMHS recNilaiMHS[DATAMAX];
bulat jmlData, i;
float rataRata;
char grade, ket[16];
printf("Berapa jumlah data = "); scanf("%d",&jmlData);
for (i=0; i<jmlData; i++)
{ cout << "Data Nilai Mahasiswa ke-" << (i+1) << endl;
printf("Nomor Pokok Mahasiswa = "); cin >> recNilaiMHS[i].npm;
printf("Persentase Kehadiran = "); scanf("%i",&recNilaiMHS[i].hadir);
printf("Nilai Tugas = "); scanf("%d",&recNilaiMHS[i].tugas);
printf("Nilai Quiz = "); scanf("%d",&recNilaiMHS[i].quiz);
printf("Nilai Tengah Semester = "); scanf("%i",&recNilaiMHS[i].nts);
printf("Nilai Akhir Semester = "); scanf("%i",&recNilaiMHS[i].nas);
}
cout << "\n" << endl;
// 1 2 3 4 5 6 7 8
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890
cout << "DAFTAR NILAI MAHASISWA" << endl;
cout << "+----------+-------+-------+-------+-------+-------+-------+-------+" << endl;
cout << "| NPM | Hadir | Tugas | Quiz | NTS | NAS | Rata2 | Grade |" << endl;
cout << "+----------+-------+-------+-------+-------+-------+-------+-------+" << endl;
for (i=0; i<jmlData; i++)
{ rataRata=(float) 0.1*recNilaiMHS[i].hadir + 0.1*recNilaiMHS[i].quiz +
0.1*recNilaiMHS[i].tugas + 0.3*recNilaiMHS[i].nts + 0.4*recNilaiMHS[i].nas;
if (rataRata>=80) { grade='A'; }
else if (rataRata>=70) { grade='B'; }
else if (rataRata>=60) { grade='C'; }
else if (rataRata>=50) { grade='D'; }
else { grade='E'; }
printf("|%10s|%7d|%7d|%7d|%7d|%7d|%7.2f| %c |\n", recNilaiMHS[i].npm,
recNilaiMHS[i].hadir, recNilaiMHS[i].tugas, recNilaiMHS[i].quiz,
recNilaiMHS[i].nts, recNilaiMHS[i].nas, rataRata, grade);
}
cout << "+----------+-------+-------+-------+-------+-------+-------+-------+";
getch();
}