#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<<"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";
for(loop=1; loop<=jk; loop++)
{
cout<<"Data ke - "<<loop;
cout<<"\nNama karyawan \t : "<<setw(20)<<karyawan[loop].name;
cout<<"\nGaji Per-bulan \t : "<<setw(20)<<karyawan[loop].gaji;
cout<<"\nStatus \t\t : "<<setw(20);;
if (karyawan[loop].status=='y')
{
cout<<"Menikah";
cout<<"\nJumlah Anak \t : "<<setw(20)<<karyawan[loop].anak<<endl;
}
else cout<<"Belum Menikah\n";
cout<<"________________________________________\n";
}
cout<<"Jumlah karyawan = "<<jk<<endl;
}
0 komentar:
Posting Komentar