No. 1
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
garis()
{puts("--------------------------------------------------------");}
int na(int uts, int uas)
{
return (uts*40/100)+(uas*60/100);
}
grade(int nilai)
{
if(nilai>=80)
return 'A';
else if(nilai>=70)
return 'B';
else if(nilai>=56)
return 'C';
else if(nilai>=47)
return 'D';
else
return 'E';
}
main()
{
int i, x;
struct
{ char nama[20], nilai_huruf;
int uts, uas, nilai_akhir;
}mhs[10];
clrscr();
cout<<endl;
cout<<"Masukkan Jumlah Data = ";cin>>x;
cout<<endl;
for(i=1;i<=x;i++)
{cout<<"Data Ke- "<<i<<endl;
cout<<"Masukkan Nama : ";gets(mhs[i].nama);
cout<<"Masukkan Nilai UTS : ";cin>>mhs[i].uts;
cout<<"Masukkan Nilai UAS : ";cin>>mhs[i].uas;
cout<<endl;
mhs[i].nilai_akhir=na(mhs[i].uts,mhs[i].uas);
mhs[i].nilai_huruf=grade(mhs[i].nilai_akhir);
}
clrscr();
garis();
cout<<"|No.| Nama | Nilai | Nilai | Nilai |"<<endl;
cout<<"| | Mahasiswa | UTS | UAS | Akhir | Huruf |"<<endl;
garis();
for(i=1;i<=x;i++)
{
cout<<setiosflags(ios::left)<<"| "<<setw(1)<<i;
cout<<setiosflags(ios::left)<<" | "<<setw(20)<<mhs[i].nama;
cout<<setiosflags(ios::right)<<" | "<<setw(3)<<mhs[i].uts;
cout<<setiosflags(ios::right)<<" | "<<setw(3)<<mhs[i].uas;
cout<<setiosflags(ios::right)<<" | "<<setw(5)<<mhs[i].nilai_akhir;
cout<<setiosflags(ios::left)<<" | "<<setw(1)<<mhs[i].nilai_huruf<<" |";
cout<<endl;
}
garis();
getch();
}
No. 2
#include <iostream.h>
#include <iomanip.h>
#include <stdio.h>
#include <conio.h>
garis()
{puts("--------------------------------------------------------------------------");}
int lembur(int jam)
{ return jam*5000; }
main()
{
int i, x;
struct
{char nama[15];
int jk, jl, hl, tl;
}kry[10];
cout<<"Masukkan Jumlah Karyawan : ";cin>>x;
cout<<endl;
for(i=1;i<=x;i++)
{
cout<<"Karyawan Ke- "<<i<<endl;
cout<<"Nama Karyawan : ";gets(kry[i].nama);
cout<<"Jumlah Jam Kerja : ";cin>>kry[i].jk;
cout<<endl;
kry[i].jl=kry[i].jk-8;
kry[i].hl=lembur(kry[i].jl);
kry[i].tl=15000+kry[i].hl;
}
cout<<endl<<endl;
garis();
cout<<"|No.| Nama | Jam | Honor | Total |"<<endl;
cout<<"| | Karyawan | Kerja | Lembur | Harian | Lembur | |"<<endl;
garis();
for(i=1;i<=x;i++)
{
cout<<setiosflags(ios::left)<<"| "<<setw(1)<<i;
cout<<setiosflags(ios::left)<<" | "<<setw(15)<<kry[i].nama;
cout<<setiosflags(ios::right)<<" | "<<setw(5)<<kry[i].jk;
cout<<setiosflags(ios::right)<<" | "<<setw(6)<<kry[i].jl;
cout<<setiosflags(ios::right)<<" | 15000 | "<<setw(8)<<kry[i].hl;
cout<<setiosflags(ios::right)<<" | "<<setw(9)<<kry[i].tl<<" |";
cout<<endl;
}
garis();
getch();
}
Semoga Bermanfaat.... ^_^
Tidak ada komentar:
Posting Komentar