Arsip Blog

Pemrograman C++ Pengaturan Gaji dengan Logika Fuzzy


#include <iostream.h>
#include<iomanip.h>
#include <stdlib.h>
#include<string.h>
#include<conio.h>

void main()
{
float tgllhr[20], blnlhr[20] , thnlhr[20], thnmsk[20], gaji[20];
float tahun,ubaru[20],ulama[20],usia[20],lamakrj[20],pencarian[20],lebih[20];
float umuda[20], utua[20], uparobaya[20],urendah[20],usedang[20],utinggi[20];
float xusia[20],xmasa[20],xgaji[20];

int x,pilusia,pilmasa,pilgaji,pilfuzzy;
char nama[20][20],jwb;
again:
clrscr();
cout<<"masukkan tahun : ";cin>>tahun;

strcpy (nama[1],"aguero");
tgllhr[1]=14;
blnlhr[1]=2;
thnlhr[1]=1984;
thnmsk[1]=2005;
gaji[1]=700;

strcpy (nama[2],"tevez");
tgllhr[2]=5;
blnlhr[2]=9;
thnlhr[2]=1974;
thnmsk[2]=2001;
gaji[2]=700;

strcpy (nama[3],"berbatov");
tgllhr[3]=15;
blnlhr[3]=9;
thnlhr[3]=1978;
thnmsk[3]=1997;
gaji[3]=500;

strcpy (nama[4],"nani");
tgllhr[4]=30;
blnlhr[4]=5;
thnlhr[4]=1965;
thnmsk[4]=1989;
gaji[4]=1200;

strcpy (nama[5],"nasri");
tgllhr[5]=17;
blnlhr[5]=6;
thnlhr[5]=1969;
thnmsk[5]=1998;
gaji[5]=1600;

strcpy (nama[6],"ireland");
tgllhr[6]=25;
blnlhr[6]=7;
thnlhr[6]=1990;
thnmsk[6]=2011;
gaji[6]=200;

strcpy (nama[7],"cicarito");
tgllhr[7]=3;
blnlhr[7]=7;
thnlhr[7]=1966;
thnmsk[7]=1989;
gaji[7]=1000;

strcpy (nama[8],"silva");
tgllhr[8]=17;
blnlhr[8]=8;
thnlhr[8]=1989;
thnmsk[8]=2010;
gaji[8]=1300;

strcpy (nama[9],"arshavin");
tgllhr[9]=16;
blnlhr[9]=8;
thnlhr[9]=1960;
thnmsk[9]=1980;
gaji[9]=2300;

strcpy (nama[10],"fabregas");
tgllhr[10]=5;
blnlhr[10]=1;
thnlhr[10]=1958;
thnmsk[10]=1982;
gaji[10]=2100;



  cout<<setiosflags(ios::right)<<setw(8)<<"     NIP";
 cout<<setiosflags(ios::right)<<setw(14)<<"    NAMA";
 cout<<setiosflags(ios::right)<<setw(12)<<"   TTL";
 cout<<setiosflags(ios::right)<<setw(23)<<"  TAHUN MASUK";
 cout<<setiosflags(ios::right)<<setw(14)<<"GAJI" <<endl;

for(x=1;x<=10;x++)
{
 cout<<setiosflags(ios::right)<<setw(7)<<thnmsk[x]<<" "<<blnlhr[x]<<thnlhr[x];
 cout<<setiosflags(ios::right)<<setw(10)<<nama[x];
 cout<<setiosflags(ios::right)<<setw(9)<<tgllhr[x]<<" "<<blnlhr[x]<<" "<<thnlhr[x];
 cout<<setiosflags(ios::right)<<setw(18)<<thnmsk[x];
 cout<<setiosflags(ios::right)<<setw(14)<<gaji[x]<<endl;

 }
 cout<<"\n\n";
 cout<<setiosflags(ios::right)<<setw(8)<<"     NIP";
 cout<<setiosflags(ios::right)<<setw(18)<<"    NAMA";
 cout<<setiosflags(ios::right)<<setw(10)<<"   USIA";
 cout<<setiosflags(ios::right)<<setw(21)<<"  LAMA KERJA";
 cout<<setiosflags(ios::right)<<setw(10)<<"GAJI" <<endl;

 for(x=1;x<=10;x++)
{
usia[x]=tahun-thnlhr[x];
lamakrj[x]=tahun-thnmsk[x];
cout<<setiosflags(ios::right)<<setw(7)<<thnmsk[x]<<" "<<blnlhr[x]<<thnlhr[x];
 cout<<setiosflags(ios::right)<<setw(14)<<nama[x];
 cout<<setiosflags(ios::right)<<setw(9)<<usia[x];
 cout<<setiosflags(ios::right)<<setw(18)<<lamakrj[x];
 cout<<setiosflags(ios::right)<<setw(14)<<gaji[x]<<endl;



if (usia[x]<=30)
{umuda[x]=1;}
else if((usia[x]>30)&&(usia[x]<40))
{umuda[x]=(40-usia[x])/10;}
else
{umuda[x]=0;}


if((usia[x]>35)&&(usia[x]<45))
{uparobaya[x]=(usia[x]-35)/10;}
else if ((usia[x]>=45)&&(usia[x]<=50))
{uparobaya[x]=(50-usia[x])/5;}
else
{uparobaya[x]=0;}

if (usia[x]>=50)
{utua[x]=1;}
else if((usia[x]>40)&&(usia[x]<50))
{utua[x]=(usia[x]-40)/10;}
else
{utua[x]=0;}

if (gaji[x]<=300)
{urendah[x]=1;}
else if((gaji[x]>300)&&(gaji[x]<800))
{urendah[x]=(800-gaji[x])/500;}
else
{urendah[x]=0;}


if((gaji[x]>500)&&(gaji[x]<1000))
{usedang[x]=(gaji[x]-500)/500;}
else if ((gaji[x]>=1000)&&(gaji[x]<=1500))
{usedang[x]=(1500-gaji[x])/500;}
else
{usedang[x]=0;}

if (gaji[x]>=2000)
{utinggi[x]=1;}
else if((gaji[x]>1000)&&(gaji[x]<2000))
{utinggi[x]=(gaji[x]-1000)/1000;}
else
{utinggi[x]=0;}

 if (lamakrj[x]<=5)
{ubaru[x]=1;}
else if((lamakrj[x]>5)&&(lamakrj[x]<15))
{ubaru[x]=(15-lamakrj[x])/10;}
else
{ubaru[x]=0;}

if((lamakrj[x]>10)&&(lamakrj[x]<25))
{ulama[x]=(lamakrj[x]-10)/15;}
else if(lamakrj[x]>= 25 )
{ulama[x]=1;
}
else
{ulama[x]=0;}
}
 cout<<"\n\nUSIA :\n";
 cout<<setiosflags(ios::right)<<setw(8)<<"     NIP";
 cout<<setiosflags(ios::right)<<setw(18)<<"    NAMA";
 cout<<setiosflags(ios::right)<<setw(10)<<"   MUDA";
 cout<<setiosflags(ios::right)<<setw(21)<<"  PAROBAYA";
 cout<<setiosflags(ios::right)<<setw(10)<<"TUA" <<endl;
 for(x=1;x<=10;x++)
{

cout<<setiosflags(ios::right)<<setw(7)<<thnmsk[x]<<" "<<blnlhr[x]<<thnlhr[x];
 cout<<setiosflags(ios::right)<<setw(14)<<nama[x];
  cout<<setiosflags(ios::right)<<setw(9)<<umuda[x];
 cout<<setiosflags(ios::right)<<setw(18)<<uparobaya[x];
 cout<<setiosflags(ios::right)<<setw(14)<<utua[x]<<endl;}

  cout<<"\n\nMASA KERJA :\n";
 cout<<setiosflags(ios::right)<<setw(8)<<"     NIP";
 cout<<setiosflags(ios::right)<<setw(18)<<"    NAMA";
 cout<<setiosflags(ios::right)<<setw(10)<<"   BARU";
 cout<<setiosflags(ios::right)<<setw(11)<<"  LAMA"<<endl;

 for(x=1;x<=10;x++)
{

cout<<setiosflags(ios::right)<<setw(1)<<thnmsk[x]<<" "<<blnlhr[x]<<thnlhr[x];
 cout<<setiosflags(ios::right)<<setw(17)<<nama[x];
  cout<<setiosflags(ios::right)<<setw(8)<<ubaru[x];
 cout<<setiosflags(ios::right)<<setw(11)<<ulama[x]<<endl;
 }


 cout<<"\n\nGAJI:\n";
 cout<<setiosflags(ios::right)<<setw(8)<<"     NIP";
 cout<<setiosflags(ios::right)<<setw(18)<<"    NAMA";
 cout<<setiosflags(ios::right)<<setw(10)<<"   RENDAH";
 cout<<setiosflags(ios::right)<<setw(21)<<"  SEDANG";
 cout<<setiosflags(ios::right)<<setw(10)<<"TINGGI" <<endl;
 for(x=1;x<=10;x++)
{

cout<<setiosflags(ios::right)<<setw(7)<<thnmsk[x]<<" "<<blnlhr[x]<<thnlhr[x];
 cout<<setiosflags(ios::right)<<setw(14)<<nama[x];
  cout<<setiosflags(ios::right)<<setw(9)<<urendah[x];
 cout<<setiosflags(ios::right)<<setw(18)<<usedang[x];
 cout<<setiosflags(ios::right)<<setw(14)<<utinggi[x]<<endl;}
 cout<<"\n\n===================================================";
 cout<<"\n\npilihan pencarian usia :\n";
 cout<<"1.no set\n2.muda\n3.parobaya\n4.tua";
 cout<<"\npilihan: ";cin>>pilusia;
  cout<<"\n\npilihan pencarian masa kerja :\n";
 cout<<"1.no set\n2.pekerja baru\n3.pekerja lama";
  cout<<"\npilihan: ";cin>>pilmasa;
  cout<<"\n\npilihan pencarian gaji :\n";
 cout<<"1.no set\n2.rendah\n3.sedang\n4.tinggi";
  cout<<"\npilihan: ";cin>>pilgaji;
 cout<<"\n\npilihan fuzzy:\n1.AND\n2.OR";
  cout<<"\npilihan: ";cin>>pilfuzzy;

 cout<<setiosflags(ios::right)<<setw(8)<<"     NIP";
 cout<<setiosflags(ios::right)<<setw(18)<<"    NAMA";
if (pilusia==2)
  {cout<<setiosflags(ios::right)<<setw(10)<<"   MUDA";}
  else if (pilusia==3)
{cout<<setiosflags(ios::right)<<setw(10)<<"   PAROBAYA";}
  else if (pilusia==4)
  {cout<<setiosflags(ios::right)<<setw(10)<<"   TUA";}
  else
 {cout<<setiosflags(ios::right)<<setw(10)<<"   NO SET";}
 if (pilmasa==2)
 {cout<<setiosflags(ios::right)<<setw(10)<<"  BARU";}
  else if (pilmasa==3)
 {cout<<setiosflags(ios::right)<<setw(10)<<"  LAMA";}
  else
 {cout<<setiosflags(ios::right)<<setw(10)<<"  NO SET";}
if (pilgaji==2)
  {cout<<setiosflags(ios::right)<<setw(10)<<"   RENDAH";}
  else if (pilgaji==3)
{cout<<setiosflags(ios::right)<<setw(10)<<"   SEDANG";}
  else if (pilgaji==4)
  {cout<<setiosflags(ios::right)<<setw(10)<<"   TINGGI";}
  else
 {cout<<setiosflags(ios::right)<<setw(10)<<"   NO SET";}
 cout<<setiosflags(ios::right)<<setw(10)<<"   PENCARIAN";
cout<<"\n";
   for(x=1;x<=10;x++)
{

cout<<setiosflags(ios::right)<<setw(1)<<thnmsk[x]<<" "<<blnlhr[x]<<thnlhr[x];
 cout<<setiosflags(ios::right)<<setw(17)<<nama[x];
 if (pilusia==2)
  {cout<<setiosflags(ios::right)<<setw(10)<<umuda[x];
  xusia[x]=umuda[x];}
  else if(pilusia==3)
 {cout<<setiosflags(ios::right)<<setw(10)<<uparobaya[x];
 xusia[x]=uparobaya[x];}
 else if(pilusia==4)
{ cout<<setiosflags(ios::right)<<setw(10)<<utua[x];
xusia[x]=utua[x];}
else
{cout<<setiosflags(ios::right)<<setw(10)<<"-";
}

 if (pilmasa==2)
  {cout<<setiosflags(ios::right)<<setw(10)<<ubaru[x];
  xmasa[x]=ubaru[x] ;}
  else if(pilmasa==3)
 {cout<<setiosflags(ios::right)<<setw(10)<<ulama[x];
 xmasa[x]=ulama[x];}
else
{cout<<setiosflags(ios::right)<<setw(10)<<"-";
}
 if (pilgaji==2)
  {cout<<setiosflags(ios::right)<<setw(10)<<urendah[x];
  xgaji[x]=urendah[x];  }
  else if(pilgaji==3)
 {cout<<setiosflags(ios::right)<<setw(10)<<usedang[x];
 xgaji[x]=usedang[x];}
 else if(pilgaji==4)
{ cout<<setiosflags(ios::right)<<setw(10)<<utinggi[x];
xgaji[x]=utinggi[x];}
else
{cout<<setiosflags(ios::right)<<setw(10)<<"-";
 }



if (pilfuzzy==1)
{
if (pilusia==1)
{
if (xmasa[x]<=xgaji[x])
{
pencarian[x]=xmasa[x];}
else
{pencarian[x]=xgaji[x];}
}
else if (pilmasa==1)
{
if (xusia[x]<=xgaji[x])
{
pencarian[x]=xusia[x];}
else
{pencarian[x]=xgaji[x];}
}
else if (pilgaji==1)
{
if (xmasa[x]<=xusia[x])
{
pencarian[x]=xmasa[x];}
else
{pencarian[x]=xusia[x];}
}
else
{
if(xusia[x]<=xmasa[x])
{if(xusia[x]<=xgaji[x])
{pencarian[x]=xusia [x]; }
else
{pencarian[x]=xgaji[x];}
 }
 else if(xmasa[x]<=xusia[x])
 {if(xmasa[x]<=xgaji[x])
 {pencarian[x]=xmasa[x];}
 else
 {pencarian[x]=xgaji[x];} }    }
 }

else if (pilfuzzy==2)
{
if(xusia[x]<=xmasa[x])
{if(xmasa[x]<=xgaji[x])
{pencarian[x]=xgaji[x]; }
else
{pencarian[x]=xmasa[x];}
 }
 else if(xmasa[x]<=xusia[x])
 {if(xusia[x]<=xgaji[x])
 {pencarian[x]=xgaji[x];}
 else
 {pencarian[x]=xusia[x];} }
 }
cout<<setiosflags(ios::right)<<setw(10)<<pencarian[x];
cout<<"\n";
 }
cout<<"Ulangi lagi? \n Y or N ";
cin>>jwb;
 if (jwb=='Y'||jwb=='y')
{goto again;}
else
{
getch();}
}

Artikel Terkait

0 komentar :

Posting Komentar

 

Catatannya Didit Copyright © 2011-2015 | Powered by Blogger