Mencatat Data Karyawan

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <conio.h>
#include <stdio.h>
using namespace std;
struct Employee_str
{
 char Name[25],status[15];
 int anak,gaji;
 char jmlh[2];
};
int main()
{
 Employee_str employee[5];
 int loop;
 for(loop=1;loop<5;loop++)
 {
  cout<<"Karyawan (1, 2, 3, ..)         : ";
  cin.getline(employee[loop].jmlh,80.);
  cout<<"Nama Karyawan "<<"                 : ";
  cin.getline(employee[loop].Name,80.);
  cout<<"Gaji/Bulan                     : ";
  cin>>employee[loop].gaji;
  cin.ignore(80,'\n');
  cout<<"Status (Menikah/Belum Menikah) : ";
  cin.getline(employee[loop].status,80.);
  cout<<"Anak (0, / 1, 2, 3, ..)        : ";
  cin>>employee[loop].anak;
  cin.ignore(80,'\n');
  cout<<endl;
 }
  cout<<"\nData Karyawan : \n";
  cout.flags(ios::left);
  cout<<setw(0)<<"No "<<" Nama\t"<<" Gaji \t"<<"  Status \t"<<"  Anak\n";
  cout<<"================================================\n";
  for(loop=1;loop<5;loop++)
 {
  cout<<setiosflags(ios::left)<<setw(4)<<loop;
  cout<<setiosflags(ios::left)<<setw(10)<<employee[loop].Name;
  cout<<setiosflags(ios::left)<<setw(10)<<employee[loop].gaji;
  cout<<setiosflags(ios::left)<<setw(20)<<employee[loop].status;
  cout<<setiosflags(ios::left)<<setw(12)<<employee[loop].anak;
  cout<<endl;
 }
 cout<<endl;
 getch();
 return 0;
}

Tugas Akhir Halaman 59 -> Tugas Akhir Pertemuan 12

No comments:

Post a Comment