Selasa, 04 Agustus 2015

Program Mencatat Data Karyawan (STRUKTUR)

#include<iostream>
#include<iomanip>
using namespace std;

struct karyawan_str
{
char name[25], status;
long int gaji;
int anak;
};

int main(){
karyawan_str karyawan[30];
int loop;
char ulangi='y';
int jk=0;

cout<<"\tDATA KARYAWAN\n";
cout<<"________________________________________\n";
for(loop=1; loop<30 && ulangi=='y'; loop++)
{
cout<<"Masukkan Nama Karyawan : ";
cin.getline(karyawan[loop].name,80,'\n');
cout<<"Gaji Per-bulan : Rp.";
cin>>karyawan[loop].gaji,80,'\n';
cout<<"Status [y=menikah | b=belum menikah] : ";
cin>>karyawan[loop].status,80,'\n';
if (karyawan[loop].status=='y')
{
cout<<"Jumlah anak : ";
cin>>karyawan[loop].anak;
}
jk++;
cout<<"\nMau Tambah Data Lagi? [y/n] : ";
cin>>ulangi;
cin.ignore(80,'\n');
}
cout<<"\n";

cout<<"\n\tDATA KARYAWAN\n";
cout<<"________________________________________________________________________\n";
cout<<"NO\tNama Karyawan\t\tGaji\t\tstatus\t\tanak\n";
cout<<"________________________________________________________________________\n";
for(loop=1; loop<=jk; loop++)
{
cout<<loop<<setw(20)<<karyawan[loop].name<<setw(15)<<karyawan[loop].gaji
<<setw(20);
if (karyawan[loop].status=='y')
{
cout<<"Menikah\t\t   "<<karyawan[loop].anak<<endl;
}
else cout<<"Belum Menikah\n";

}
cout<<"________________________________________________________________________\n";
cout<<"Jumlah karyawan = "<<jk<<endl;
}

Share:

1 komentar:

index

Popular Posts