Thursday, May 24, 2018

CODING C++ PENGAJIAN KARYAWAN

#include <conio>
#include <iostream>
#include <stdlib>
#include <fstream>
#include <string>
#include <stdio>
#include <iomanip>

void gajikar(int gaji, long int &totalgaji);

struct karyawan
{
    char no[10];
    char nama[25];
    int grade;
    int jam;
}kar;

main()
{
     long int totalgaji,total=0;
     long int gaji,gajikecil=100000000;
     char n[10];
     char nm[25];
     long int gajibesar=0;
     char N[10];
     char NM[25];
     ifstream File("gaji.txt",ios::in);
     if(!File)
     {
         cerr<<"File not found";
         exit(1);
     }
     cout<<"----------------------------------------------------------------------------\n";
    cout<<setiosflags(ios::left)<<setw(4)<<"No."<<setw(10)<<"No. Induk"<<setw(25)
    <<"Nama Karyawan"<<setw(6)<<"Grade"<<setw(10)<<"Jam Kerja"<<setw(11)
    <<"Jam Lembur"<<setw(11)<<"Total Gaji"<<endl;
    cout<<"----------------------------------------------------------------------------\n";
    File.read((char*)&kar, sizeof(kar));        ;
    while(!File.eof())
    {

        if(kar.grade==1)
        {
            gaji=8000000;
        }
        else if(kar.grade==2)
        {
            gaji=6000000;
        }
        else if(kar.grade==3)
        {
            gaji=5000000;
        }
        else if(kar.grade==4)
        {
            gaji=4000000;
        }
        gajikar(gaji,totalgaji);
        if(gajikecil>=totalgaji)
        {
             gajikecil=totalgaji;
             strcpy(n,kar.no);
             strcpy(nm,kar.nama);
        }
        if(gajibesar<=totalgaji)
        {
             gajibesar=totalgaji;
             strcpy(N,kar.no);
             strcpy(NM,kar.nama);
        }
        total=totalgaji+total;
        File.read((char*)&kar, sizeof(kar));
    }
    File.close();
    cout<<"----------------------------------------------------------------------------\n";
    cout<<"Total Gaji Seluruhnya yang diterima = "<<total<<endl;
    cout<<"\nKaryawan gajinya yang terkecil : \n";
    cout<<"No. Induk : "<<n;
    cout<<"\nNama      : "<<nm;
    cout<<"\nGaji      : "<<gajikecil;
    cout<<"\n\nKaryawan gajinya yang terbesar : \n";
    cout<<"No. Induk : "<<N;
    cout<<"\nNama      : "<<NM;
    cout<<"\nGaji      : "<<gajibesar;
    getch();
}

long int upah;
int lembur;
int nmr=0;

void gajikar(int gaji, long int &totalgaji)
{
     upah = 0;
     lembur = 0;
     nmr++;

     if(kar.jam>=160)
     {
         lembur = kar.jam-160;
         upah = lembur*20000;
     }
     totalgaji = gaji+upah;
     cout<<setiosflags(ios::left)<<setw(4)<<nmr<<setw(10)<<kar.no<<setw(25)
         <<kar.nama<<setw(6)<<kar.grade<<setw(10)<<kar.jam<<setw(11)
         <<lembur<<setw(11)<<totalgaji<<endl;
}

1 comment:

  1. How do I make money from playing games and earning
    These wooricasinos.info are the three most popular forms of หารายได้เสริม gambling, 토토 and are gri-go.com explained in a very concise and concise manner. The most kadangpintar common forms of gambling are:

    ReplyDelete

CONTOH CODING LINKED LIST MENGGUNAKAN BORLAND C++

CONTOH CODING LINKED LIST MENGGUNAKAN BORLAND C++ #include<stdlib.h> #include<conio.h> #include<iostream.h> struc...