Program Perhitungan Gaji

//Deklarasi Header
#include<stdio.h>
#include<iostream.h>
#include<conio.h>

main()
{
//Deklarasi Struct & Variable
struct
{
    char kd_jab,*jabatan,kd_status,*status;
    long gapok, tunjangan;
}gaji;

char tanggal[20],nip[6], nama[25];
long total;

//Deklarasi Input
cout<<"         DAFTAR GAJI KARYAWAN       "<<endl;
cout<<"           PT.NGALOR NGIDUL         "<<endl;
cout<<endl;
cout<<"Tanggal              : ";gets(tanggal);
cout<<endl;
cout<<"NIP                  : ";cin>>nip;
cout<<"Nama Karyawan        : ";gets(nama);
ulang_kd_jab:
cout<<"Kode Jabatan [1/2]   : ";cin>>gaji.kd_jab;
ulang_kd_status:
cout<<"Kode Status [M/S]    : ";cin>>gaji.kd_status;

//Deklarasi Percabangan
if (gaji.kd_jab == '1')
   {
    gaji.jabatan = "Administrasi"; gaji.gapok = 800000;
    if (gaji.kd_status == 'M' || gaji.kd_status == 'm')
    {
        gaji.status = "Menikah"; gaji.tunjangan = 200000;
    }
    else
        if (gaji.kd_status == 'S' || gaji.kd_status == 's')
    {
        gaji.status = "Single"; gaji.tunjangan = 100000;
    }
        else
            { cout << "Kode status salah...!"<<endl; goto ulang_kd_status;}
   }

else
    if (gaji.kd_jab == '2')
    {
    gaji.jabatan = "Operasional"; gaji.gapok = 850000;
    if (gaji.kd_status == 'M' || gaji.kd_status == 'm')
    {
        gaji.status = "Menikah"; gaji.tunjangan = 250000;
    }
    else
        if (gaji.kd_status == 'S' || gaji.kd_status == 's')
    {
        gaji.status = "Single"; gaji.tunjangan = 150000;
    }
        else
            { cout << "Kode status salah...!"<<endl; goto ulang_kd_status;}
   }
else
{ cout << "Kode jabatan salah...!"<<endl; goto ulang_kd_jab;}

total = gaji.gapok + gaji.tunjangan;

//Deklarasi output
clrscr();

cout<<"         DAFTAR GAJI KARYAWAN       "<<endl;
cout<<"           PT.NGALOR NGIDUL         "<<endl;
cout<<endl;
cout<<"Tanggal              : "<<tanggal<<endl;
cout<<"===================================="<<endl;
cout<<"NIP                  : "<<nip<<endl;
cout<<"Nama Karyawan        : "<<nama<<endl;
cout<<"Kode Jabatan         : "<<gaji.kd_jab<<endl;
cout<<"Jabatan              : "<<gaji.jabatan<<endl;
cout<<"Gaji pokok           : "<<gaji.gapok<<endl;
cout<<"Kode Status          : "<<gaji.kd_status<<endl;
cout<<"Status pegawai       : "<<gaji.status<<endl;
cout<<"Tunjangan            : "<<gaji.tunjangan<<endl;
cout<<"Total                : "<<total;
getch();
}

0 comments:

Post a Comment