Program Array Cetak Nilai
- ..
#include <conio.h>
#include <stdio.h>
#include <iomanip.h>
main()
{
char nama[35][25],nakhir;
float ntugas[25], nuts[25], nuas[25], rata;
char YT;
int hal=0,no=0,brs=0,j_data=0, kertas_kosong=0;
do
{
clrscr();
j_data++;
#include <stdio.h>
#include <iomanip.h>
main()
{
char nama[35][25],nakhir;
float ntugas[25], nuts[25], nuas[25], rata;
char YT;
int hal=0,no=0,brs=0,j_data=0, kertas_kosong=0;
do
{
clrscr();
j_data++;
cout<<"Entry Data Nilai Mahasiswa "<<endl;
cout<<"Maximum 25 Data, dan Sekarang adalah Data Ke : "<<j_data<<endl<<endl;
cout<<"Nama Mahasiswa : ";gets(nama[j_data]);
cout<<"Nilai Tugas : ";cin>>ntugas[j_data];
cout<<"Nilai UTS : ";cin>>nuts[j_data];
cout<<"Nilai UAS : ";cin>>nuas[j_data];
cout<<endl<<endl;
cout<<"Data Berikutnya [Y/T] : ";cin>>YT;
}while((YT=='y')||(YT=='Y'));
for (no=1; no<=j_data; no++)
{
if (kertas_kosong==0)
{
clrscr();
hal++;
cout<<"Daftar Nilai Mahasiswa"<<endl;cout<<endl;
cout<<" Hal : "<<hal;cout<<endl;
cout<<"-----+--------------+-------------------------+--------+-----------"<<endl;
cout<<"No. |N A M A |N. Tugas |N. UTS |N. UAS |N. Rata | N. Akhir "<<endl;
cout<<"-----+--------------+-------------------------+--------+-----------"<<endl;
kertas_kosong=1;
}
rata=(ntugas[no]+nuts[no]+nuas[no])/3;
if (rata>=85)
nakhir='A';
else
if (rata>=70)
nakhir='B';
else
if (rata>=60)
nakhir='C';
else
if (rata>=50)
nakhir='D';
else
nakhir='E';
brs++;
cout<<setfill(' ')<<setw(4)<<no<<" |"<<nama[no]<<setw(16-strlen(nama[no]))<<" | "<<
setw(7)<<ntugas[no]<<" |"<<setw(6)<<nuts[no]<<
" |"<<setw(6)<<nuas[no]<<" |"<<setw(6)<<rata<<" | "<<setw(6)<<nakhir<<endl;
if (brs==5)
{
cout<<"-----+--------------+-------------------------+--------+-----------"<<endl;
cout<<" Tekan Enter Untuk Melanjutkan ............. "<<endl;
getch();
kertas_kosong=0;
brs=0;
}
}
cout<<"-----+--------------+-------------------------+--------+-----------"<<endl;
cout<<" Data Habis .................. "<<endl;
getch();
return 0;
}