You are on page 1of 3

import java.util.

Scanner;

public class Fuzzy {
float memberIPKBuruk = 0 ;
float memberIPKCukup = 0 ;
float memberIPKBagus = 0 ;
float memberGajiKecil = 0 ;
float memberGajiSedang = 0 ;
float memberGajiBesar = 0 ;
float memberGajiSgtBesar = 0 ;

public void anggotaIPK(float inputIPK) {
//mencek keanggotaan linguistik "Buruk"
if(inputIPK <= 2.0) {
memberIPKBuruk = 1;
}
else {
if(inputIPK < 2.75) {
memberIPKBuruk = (float)((-inputIPK + 2.75)/0.75);
}
else memberIPKBuruk = 0;
}
//mencek keanggotaan linguistik "Cukup"
if((inputIPK <= 2.0)||(inputIPK >= 3.25)) {
memberIPKCukup = 0;
}
else {
if(inputIPK < 2.75) {
memberIPKCukup = (float)((inputIPK - 2)/0.75);
}
else {
if(inputIPK > 2.75 && inputIPK < 3.25) {
memberIPKCukup = (float)((-inputIPK +
3.25)/0.5);
}
else memberIPKCukup = 1;
}
}
//mencek keanggotaan linguistik "Bagus"
if(inputIPK <= 2.75) {
memberIPKBagus = 0;
}
else {
if(inputIPK < 3.25) {
memberIPKBagus = (float)((inputIPK - 2.75)/0.5);
}
else memberIPKBagus = 1;
}
}

public void anggotaGaji(float inputGaji) {
//mencek keanggotaan linguistik "Kecil"
if(inputGaji <= 1.0) {
memberGajiKecil = 1;
}
else {
if(inputGaji < 3.0) {
memberGajiKecil = (float)((-inputGaji + 3.0)/2.0);
}

0) { memberGajiSedang = 1.println("Kecil = " + memberGajiKecil ). System.println("Buruk = " + memberIPKBuruk ). } } //mencek keanggotaan linguistik "SangatBesar" if(inputGaji >= 12.6.out.4.00 ) { memberGajiSgtBesar = (float)((inputGaji - 7.0 )) { memberGajiBesar = (float)((-inputGaji + 12. } .0 )) { memberGajiSedang = (float)((-inputGaji . } else memberGajiSgtBesar = 0.out. System.0) { memberGajiSedang = (float)((inputGaji .println("Nilai fuzzy IPK = " ).0 && inputGaji < 6. System.println("Bagus = " + memberIPKBagus ).0){ memberGajiBesar = (float)((inputGaji .out.0).0).println("Nilai fuzzy Gaji = " ). } else memberGajiSedang = 0 .println("Sangat Besar = " + memberGajiSgtBesar).out. System. } else { if(inputGaji > 7.println("Besar = " + memberGajiBesar ).0)/2.1. System.0) { memberGajiBesar = 1.out.0). } else { if((inputGaji > 7. } else { if(inputGaji > 4.out.println("Cukup = " + memberIPKCukup ). System.0)/2.out.0)/5. } else memberGajiBesar = 0 .0 && inputGaji < 12. } else { if((inputGaji > 4. } } public void cetakMember() { System. } //mencek keanggotaan linguistik "Sedang" if(inputGaji >= 3. System.out.println("Sedang = " + memberGajiSedang ). } } //mencek keanggotaan linguistik "Besar" if(inputGaji >= 6. else memberGajiKecil = 0.out.0) { memberGajiSgtBesar = 1.0 && inputGaji < 12. System. } else { if(inputGaji < 3.0)/2.0 && inputGaji <= 4.0 && inputGaji <= 7.0)/5.0) && (inputGaji < 6.0).0).

nextFloat().out. System. gaji = input.anggotaIPK(ipk). Fuzzy test = new Fuzzy(). System. test. test.nextFloat(). ipk = input.out. float gaji.print("Masukkan nilai Gaji = "). test.in). Scanner input = new Scanner(System.close(). } } . input.anggotaGaji(gaji).} class TestFuzzy { public static void main(String[] args) { float ipk.cetakMember().print("Masukkan nilai IPK = ").