#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
struct pegawai
{
char nik[9];
char nama[20];
char kd[5];
char jabatan;
} peg[20];
void main()
{
char lg='Y';
int hasil,i,n=0;
float gaji=0;
long tunjangan;
long tgaji=0;
while(lg=='Y'||lg=='y')
{
clrscr();
cout<<"Input Data Pegawai\n";
cout<<"-----------------------------------\n";
n++;
cout<<"NIK :";
gets(peg[i].nik);
cout<<"Nama :";
gets(peg[i].nama);
cout<<"kd[1,2,3] :";
gets(peg[i].kd);
cout<<"Input Lagi[Y/T] :";
lg=getche();
}
clrscr();
gotoxy(5,3);cout<<"LAPORAN GAJI PEGAWAI \n";
gotoxy(5,4);cout<<"----------------------------------------------------\n";
gotoxy(5,5);cout<<"Kode NIK Nama Jabatan Gaji Tunjangan TGaji \n";
gotoxy(5,6);cout<<"--------------------------------------------------- \n";
for(i=1;i<=n;i++)
{
gotoxy(6,6+i);cout<<i;
gotoxy(9,6+i);cout<<peg[i].nik;
gotoxy(17,6+i);cout<<peg[i].nama;
gotoxy(35,6+i);cout<<peg[i].kd;
hasil=strcmp(peg[i].kd,"1");
if(hasil==0)
jabatan="Persediaan";
gaji=2500000;
hasil=strcmp(peg[i].kd,"2");
if(hasil==0)
jabatan="Administrasi";
gaji=2000000;
hasil=strcmp(peg[i].kd,"3");
if(hasil==0)
jabatan="Keuangan";
gaji=1500000;
gotoxy(45,6+i);cout<<gaji;
gotoxy(48,6+i);cout<<jabatan;
hasil=strcmp(peg[i].kd,"1");
if(hasil==0)
tunjangan=0.35*gaji;
hasil=strcmp(peg[i].kd,"2");
if(hasil==0)
tunjangan=0.10*gaji;
hasil=strcmp(peg[i].kd,"3");
if(hasil==0)
tunjangan=0.05*gaji;
gotoxy(45,6+i);cout<<tunjangan;
tgaji= gaji + tunjangan;
gotoxy(50,6+i);cout<<tgaji;
}
gotoxy(5,7+i);cout<<"--------------------------------------------";
getch();
}
pak ini jawaban No;3 ya pak
BalasHapus