Perancangan Sistem Pakar untuk Mendiagnosis Penyakit Anemia dengan Menggunakan Metode Dempster-Shafer Berbasis Android
LISTING PROGRAM
1. Kode Program Menu
Dasboard
:
package com.anemia;
import android.app.Activity; import android.content.Intent;
import android.content.SharedPreferences; import android.os.Bundle;
import android.os.StrictMode; import android.view.View; import android.widget.Button;
public class DashboardActivity extends Activity { Button btnLogout;
Button btnDiagnosis; Button btnAnemia;
SessionManager session; @Override
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
session = new SessionManager(getApplicationContext()); String sts = String.valueOf(session.isLoggedIn());
if(sts.equals("true")){
setContentView(R.layout.dashboard);
btnLogout = (Button) findViewById(R.id.btnLogout);
btnDiagnosis = (Button) findViewById(R.id.btnDiagnosis); btnAnemia = (Button) findViewById(R.id.btnAnemia);
btnLogout.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) { // TODO Auto-generated method stub
session.logoutUser();
finish();
}
});
btnDiagnosis.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent diagnosis = new Intent(getApplicationContext(), Diagnosis.class);
startActivity(diagnosis); }
});
btnAnemia.setOnClickListener(new View.OnClickListener() {
(2)
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent anemia = new Intent(getApplicationContext(), Anemia.class);
startActivity(anemia);
}
}); }else{
// user is not logged in show login screen Intent login = new Intent(getApplicationContext(), LoginActivity.class);
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(login);
// Closing dashboard screen finish();
} } }
2. Kode Program Menu Diagnosis:
package com.anemia;import java.io.BufferedReader; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileReader;
import java.io.FileWriter; import java.io.IOException; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Set; import java.util.TreeSet; import com.ds.Update;
import android.app.Activity; import android.content.Intent;
import android.content.SharedPreferences; import android.os.Bundle;
import android.os.Environment; import android.view.View; import android.widget.Button; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.Toast;
public class Pertanyaan17 extends Activity {
public static final String PREFS_NAME = "MyPreferencesFile"; Button btnp3;
private RadioGroup radioPertanyaanGroup; private RadioButton radioPertanyaanButton;
@Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
(3)
setContentView(R.layout.pertanyaan17); btnp3 = (Button) findViewById(R.id.btnp3); radioPertanyaanGroup = (RadioGroup)
findViewById(R.id.radioPertanyaan);
btnp3.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) {
int selectedId = radioPertanyaanGroup.getCheckedRadioButtonId();
radioPertanyaanButton = (RadioButton) findViewById(selectedId);
String jawaban = radioPertanyaanButton.getText().toString();
int p1 = 0 ; int p2 = 0 ; int p3 = 0 ; int p4 = 0 ; int p5 = 0 ; int p6 = 0 ; int p7 = 0 ; int p8 = 0 ; int p9 = 0 ; int p10 = 0 ; int p11 = 0 ; int p12 = 0 ; int p13 = 0 ; int p14 = 0 ; int p15 = 0 ;int p16 = 0 ; int p17 = 0 ;
double teta_total = 0; double total_gejala = 0 ; Update update = new Update();
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
String g1 = settings.getString("diagnosis1", null); String g2 = settings.getString("diagnosis2", null); String g3 = settings.getString("diagnosis3", null); String g4 = settings.getString("diagnosis4", null); String g5 = settings.getString("diagnosis5", null); String g6 = settings.getString("diagnosis6", null); String g7 = settings.getString("diagnosis7", null); String g8 = settings.getString("diagnosis8", null); String g9 = settings.getString("diagnosis9", null); String g10 = settings.getString("diagnosis10", null); String g11 = settings.getString("diagnosis11", null); String g12 = settings.getString("diagnosis12", null); String g13 = settings.getString("diagnosis13", null); String g14 = settings.getString("diagnosis14", null); String g15 = settings.getString("diagnosis15", null); String g16 = settings.getString("diagnosis16", null); if(g1.equals("Ya")){ p1 = 1; }
if(g2.equals("Ya")){ p2 = 1; } if(g3.equals("Ya")){ p3 = 1; } if(g4.equals("Ya")){ p4 = 1; } if(g5.equals("Ya")){ p5 = 1; } if(g6.equals("Ya")){ p6 = 1; } if(g7.equals("Ya")){ p7 = 1; } if(g8.equals("Ya")){ p8 = 1; } if(g9.equals("Ya")){ p9 = 1; } if(g10.equals("Ya")){ p10 = 1; } if(g11.equals("Ya")){ p11 = 1; } if(g12.equals("Ya")){ p12 = 1; } if(g13.equals("Ya")){ p13 = 1; } if(g14.equals("Ya")){ p14 = 1; } if(g15.equals("Ya")){ p15 = 1; } if(g16.equals("Ya")){ p16 = 1; }
(4)
int total =
p1+p2+p3+p4+p5+p6+p7+p8+p9+p10+p11+p12+p13+p14+p15+p16+p17; if(total<4){
Toast.makeText(Pertanyaan17.this, "minimum pertanyaan yang dijawab 4 silahkan ulangi", Toast.LENGTH_SHORT).show();
Intent pp = new Intent(getApplicationContext(), Pertanyaan1.class);
startActivity(pp); }
else{
if(p1 == 1){ double densitas_gejala = 0.8;
double teta_gejala = 1- densitas_gejala teta_total = teta_gejala;
String a = "aa,ah,CetakHimpunan( a, densitas_gejala);
total_gejala += 1; }
System.out.println("================Batas Perulangan============================");
if(p2 == 1){
double densitas_gejala = 0.8;
double teta_gejala = 1- densitas_gejala String a = "ad,ak,ah," ;
if (total_gejala == 0){ teta_total = teta_gejala;
CetakHimpunan( a, densitas_gejala);
} else{
Teta(teta_gejala); Irisan(a, teta_gejala , densitas_gejala, teta_total);
update.run();
double hk = update.himpunan_kosong(); teta_total = ((teta_total * teta_gejala)/hk);
} }
System.out.println("================Batas Perulangan============================");
if(p3 == 1){
double densitas_gejala = 0.8; double teta_gejala = 1- densitas_gejala;
String a = "aa,ad,ak," ; if (total_gejala == 0){
(5)
teta_total = teta_gejala;
CetakHimpunan( a, densitas_gejala); }
else{
Teta(teta_gejala);
Irisan(a, teta_gejala , densitas_gejala, teta_total);
update.run();
double hk = update.himpunan_kosong(); teta_total = ((teta_total * teta_gejala)/hk);
} }
if(p4 == 1){
double densitas_gejala = 0.8; double teta_gejala = 1- densitas_gejala;
String a = "ak," ; if (total_gejala == 0){ teta_total = teta_gejala;
CetakHimpunan( a, densitas_gejala); }
else{
Teta(teta_gejala);
Irisan(a, teta_gejala , densitas_gejala, teta_total);
update.run();
double hk = update.himpunan_kosong(); teta_total = ((teta_total * teta_gejala)/hk);
} }
if(p5 == 1){
double densitas_gejala = 0.8; double teta_gejala = 1- densitas_gejala;
String a = "ak," ; if (total_gejala == 0){ teta_total = teta_gejala;
CetakHimpunan( a, densitas_gejala); }
else{
(6)
Irisan(a, teta_gejala , densitas_gejala, teta_total);
update.run();
double hk = update.himpunan_kosong(); teta_total = ((teta_total * teta_gejala)/hk);
} }
if(p6 == 1){
double densitas_gejala = 0.9; double teta_gejala = 1- densitas_gejala;
String a = "ah," ; if (total_gejala == 0){ teta_total = teta_gejala;
CetakHimpunan( a, densitas_gejala); }
else{
Teta(teta_gejala);
Irisan(a, teta_gejala , densitas_gejala, teta_total);
update.run();
double hk = update.himpunan_kosong(); teta_total = ((teta_total * teta_gejala)/hk);
} }
if(p7 == 1){
double densitas_gejala = 0.9; double teta_gejala = 1- densitas_gejala;
String a = "ad," ; if (total_gejala == 0){ teta_total = teta_gejala;
CetakHimpunan( a, densitas_gejala); }
else{
Teta(teta_gejala);
Irisan(a, teta_gejala , densitas_gejala, teta_total);
update.run();
(7)
teta_total = ((teta_total * teta_gejala)/hk);
} }
if(p8 == 1){
double densitas_gejala = 0.9; double teta_gejala = 1- densitas_gejala;
String a = "ad," ; if (total_gejala == 0){ teta_total = teta_gejala;
CetakHimpunan( a, densitas_gejala); }
else{
Teta(teta_gejala);
Irisan(a, teta_gejala , densitas_gejala, teta_total);
update.run();
double hk = update.himpunan_kosong(); teta_total = ((teta_total * teta_gejala)/hk);
} }
if(p9 == 1){
double densitas_gejala = 0.8; double teta_gejala = 1- densitas_gejala;
String a = "ad," ; if (total_gejala == 0){ teta_total = teta_gejala;
CetakHimpunan( a, densitas_gejala); }
else{
Teta(teta_gejala);
Irisan(a, teta_gejala , densitas_gejala, teta_total);
update.run();
double hk = update.himpunan_kosong(); teta_total = ((teta_total * teta_gejala)/hk);
}
(8)
}
if(p10 == 1){
double densitas_gejala = 0.8; double teta_gejala = 1- densitas_gejala;
String a = "ad," ; if (total_gejala == 0){ teta_total = teta_gejala;
CetakHimpunan( a, densitas_gejala); }
else{
Teta(teta_gejala);
Irisan(a, teta_gejala , densitas_gejala, teta_total);
update.run();
double hk = update.himpunan_kosong(); teta_total = ((teta_total * teta_gejala)/hk);
}
} if(p11 == 1){
double densitas_gejala = 0.9; double teta_gejala = 1- densitas_gejala;
String a = "ah," ; if (total_gejala == 0){ teta_total = teta_gejala;
CetakHimpunan( a, densitas_gejala); }
else{
Teta(teta_gejala);
Irisan(a, teta_gejala , densitas_gejala, teta_total);
update.run();
double hk = update.himpunan_kosong(); teta_total = ((teta_total * teta_gejala)/hk);
}
}
if(p12 == 1){
double densitas_gejala = 0.8; double teta_gejala = 1- densitas_gejala;
(9)
if (total_gejala == 0){ teta_total = teta_gejala;
CetakHimpunan( a, densitas_gejala); }
else{
Teta(teta_gejala);
Irisan(a, teta_gejala , densitas_gejala, teta_total);
update.run();
double hk = update.himpunan_kosong(); teta_total = ((teta_total * teta_gejala)/hk);
} }
if(p13 == 1){
double densitas_gejala = 0.8; double teta_gejala = 1- densitas_gejala;
String a = "ah," ; if (total_gejala == 0){ teta_total = teta_gejala;
CetakHimpunan( a, densitas_gejala); }
else{
Teta(teta_gejala);
Irisan(a, teta_gejala , densitas_gejala, teta_total);
update.run();
double hk = update.himpunan_kosong(); teta_total = ((teta_total * teta_gejala)/hk);
} }
if(p14 == 1){
double densitas_gejala = 0.8; double teta_gejala = 1- densitas_gejala;
String a = "ad," ; if (total_gejala == 0){ teta_total = teta_gejala;
CetakHimpunan( a, densitas_gejala); }
(10)
else{
Teta(teta_gejala);
Irisan(a, teta_gejala , densitas_gejala, teta_total);
update.run();
double hk = update.himpunan_kosong(); teta_total = ((teta_total * teta_gejala)/hk);
}
}
if(p15 == 1){ double densitas_gejala = 0.8; double teta_gejala = 1- densitas_gejala;
String a = "aa," ; if (total_gejala == 0){ teta_total = teta_gejala;
CetakHimpunan( a, densitas_gejala); }
else{
Teta(teta_gejala);
Irisan(a, teta_gejala , densitas_gejala, teta_total);
update.run();
double hk = update.himpunan_kosong(); teta_total = ((teta_total * teta_gejala)/hk);
}
}
if(p16 == 1){
double densitas_gejala = 0.7; double teta_gejala = 1- densitas_gejala;
String a = "ad," ; if (total_gejala == 0){ teta_total = teta_gejala;
CetakHimpunan( a, densitas_gejala); }
else{
Teta(teta_gejala);
Irisan(a, teta_gejala , densitas_gejala, teta_total);
(11)
update.run();
double hk = update.himpunan_kosong(); teta_total = ((teta_total * teta_gejala)/hk);
} }
if(p17 == 1){
double densitas_gejala = 0.8; double teta_gejala = 1- densitas_gejala;
String a = "ad," ; if (total_gejala == 0){ teta_total = teta_gejala;
CetakHimpunan( a, densitas_gejala); }
else{
Teta(teta_gejala);
Irisan(a, teta_gejala , densitas_gejala, teta_total);
update.run();
double hk = update.himpunan_kosong(); teta_total = ((teta_total * teta_gejala)/hk);
} }
/// ambil kesimpulan double mAA = 0;
double mAD = 0; double mAK = 0; double mAH = 0;
double mAAAD = 0; double mAAAK = 0; double mAAAH = 0; double mADAK = 0; double mADAH = 0; double mAAADAK = 0; double mAAADAH = 0; double mADAKAH = 0; double mAAADAKAH = 0;
File folder = new
File(Environment.getExternalStorageDirectory() + "/ds"); String csvFile =
(12)
BufferedReader br = null; String line = "";
String cvsSplitBy = "#";
try {
br = new BufferedReader(new FileReader(csvFile));
while ((line = br.readLine()) != null) {
// use comma as separator String[] country =
line.split(cvsSplitBy);
String a = country[0]; Double b
=Double.parseDouble(country[1]);
if (a.equals("aa,")){ mAA = b;
} else if(a.equals("ad,")){
mAD = b; }
else if(a.equals("ak,")){ mAK
= b;
} else if(a.equals("ah,")){
mAH = b;
} else if(a.equals("aa,ad,")){ mAAAD = b;
} else if(a.equals("aa,ak,")){ mAAAK = b;
} else if(a.equals("aa,ah,")){
mAAAH = b;
}
else if(a.equals("ad,ak,")){ mADAK = b;
}
(13)
mADAH = b; }
else if(a.equals("aa,ad,ak,")){ mAAADAK = b;
} else if(a.equals("aa,ad,ah,")){
mAAADAH = b;
} else if(a.equals("ad,ak,ah,")){
mADAKAH = b;
} else if(a.equals("aa,ad,ak,ah")){ mAAADAKAH = b;
}
}
} catch (FileNotFoundException e) { e.printStackTrace();
} catch (IOException e) { e.printStackTrace(); } finally {
if (br != null) { try {
br.close();
} catch (IOException e) { e.printStackTrace(); }
} }
double m1, m2, m3, m4, m5, m6 , m7, m8, m9,m10, m11, m12;
m1 = Math.max(mAA, mAD); m2 = Math.max(m1, mAK); m3 = Math.max(m2, mAH); m4 = Math.max(m3, mAAAD); m5 = Math.max(m4, mAAAK); m6 = Math.max(m5, mAAAH); m7 = Math.max(m6, mADAK); m8 = Math.max(m7, mADAH); m9 = Math.max(m8, mAAADAK); m10 = Math.max(m9, mAAADAH); m11 = Math.max(m10, mADAKAH); m12 = Math.max(m11, mAAADAKAH); String gejala = "";
if (m12== mAA){
gejala = "Anemia Amplastik"; }
(14)
else if(m12== mAD){
gejala = " Anemia Defisiensi Besi ";
}
else if(m12== mAK){
gejala = "Anemia Penyakit Kronis";
} else if(m12== mAH){
gejala = "Anemia Hemolitik "; } else if(m12== mAAAD){
gejala = "Anemia Amplastik atau Anemia Defisiensi Besi ";
} else if(m12== mAAAK){
gejala = "Anemia Amplastik atau Anemia Penyakit Kronis ";
} else if(m12== mAAAH){
gejala = "Anemia Amplastik atau Anemia Hemolitik "; }
else if(m12== mADAK){
gejala = "Anemia Deisiensi atau Anemia Penyakit Kronis ";
}
else if(m12== mADAH){
gejala = "Anemia Deisiensi atau Anemia Hemolitik ";
}
else if(m12== mAAADAK){
gejala = "Anemis Amplastik Anemia Deisiensi Besi atau Anemia Penyakit Kronis ";
}
else if(m12== mAAADAH){
gejala = "Anemis Amplastik Anemia Deisiensi Besi atau Anemia Hemolitik ";
}
(15)
gejala = " Anemia Deisiensi atau Anemia Penyakit Kronis atau Anemia Hemolitik ";
}
else if(m12== mAAADAKAH){
gejala = "Anemia Amplastik atau Anemia Deisiensi Besi atau Anemia Penyakit Kronis atau Anemia
Hemolitik ";
} else{
gejala = "Tidak ditemukan"; }
SharedPreferences.Editor editor = settings.edit();
editor.putString("gejala", gejala); editor.commit();
;
Intent pp = new Intent(getApplicationContext(), Kesimpulan.class);
startActivity(pp);
}
} }); }
public static double bulat(double angka){ double r = 0;
int decimalPlace = 6;
BigDecimal bd = new BigDecimal(angka);
bd = bd.setScale(decimalPlace,BigDecimal.ROUND_UP); r = bd.doubleValue();
return r; }
private static void CetakHimpunan( String a , double densitas_gejala ) {
try {
File folder = new
File(Environment.getExternalStorageDirectory() + "/ds"); String csv = folder.toString()+"/"+"himpunan.csv"; FileWriter writer = new FileWriter(csv);
///Set<String> setA = new HashSet<String>(Arrays.asList(a)); writer.append(""+a); writer.append("#");
writer.append(""+densitas_gejala); writer.append("\n");
(16)
writer.flush(); writer.close();
}
catch(IOException e) {
e.printStackTrace(); }
}
private static void Teta(double teta_gejala) {
List<String> lists1 = new ArrayList<String>(); List<String> lista1 = new ArrayList<String>(); File folder = new
File(Environment.getExternalStorageDirectory() + "/ds");
String csvFile = folder.toString()+"/"+"himpunan.csv";
BufferedReader br = null; String line = "";
String cvsSplitBy = "#";
int n = 0; try {
br = new BufferedReader(new FileReader(csvFile)); while ((line = br.readLine()) != null) {
// use comma as separator
String[] himpunan = line.split(cvsSplitBy);
String str2 = himpunan[0]; //himpunan lama double densitas_b =
Double.parseDouble(himpunan[1]) ;
lists1.add(str2);
double cbt = bulat((teta_gejala * densitas_b));
lista1.add(String.valueOf(cbt));
}
} catch (FileNotFoundException e) { e.printStackTrace();
} catch (IOException e) { e.printStackTrace(); } finally {
if (br != null) { try {
br.close();
(17)
e.printStackTrace(); }
} }
try
{
String csv = folder.toString()+"/"+"teta.csv"; FileWriter writer = new FileWriter(csv); for(int m= 0 ; m <lists1.size() ; m++){
writer.append(lists1.get(m)); writer.append('#');
writer.append(lista1.get(m)); writer.append('\n');
}
writer.flush(); writer.close();
}//end ststement try penulisan catch(IOException e)
{
e.printStackTrace(); }
}
private static void Irisan(String a , double teta_gejala, double densitas_gejala ,double teta_total)
{
File folder = new
File(Environment.getExternalStorageDirectory() + "/ds");
String csvFile = folder.toString()+"/"+"himpunan.csv";
BufferedReader br = null; String line = "";
String cvsSplitBy = "#";
List<String> sethuruf = new ArrayList<String>(); List<String> setangka = new ArrayList<String>(); int n = 0;
try {
br = new BufferedReader(new FileReader(csvFile)); while ((line = br.readLine()) != null) {
// use comma as separator
String[] himpunan = line.split(cvsSplitBy); String str1 = a; // himpunan baru
(18)
String str3 = himpunan[1];
double densitas_b = 0; try{
densitas_b = Double.parseDouble(str3) ; }catch(NumberFormatException e){
throw new RuntimeException(str3 + " is not a number");
}
TreeSet<String> set1 = new TreeSet<String>(); TreeSet<String> set2 = new TreeSet<String>(); ArrayList aList= new
ArrayList(Arrays.asList(str1.split(",")));
ArrayList bList= new ArrayList(Arrays.asList(str2.split(",")));
for(int i=0;i<aList.size();i++) {
String k = String.valueOf(aList.get(i));
set1.add(k); }
for(int j=0;j<bList.size();j++) {
String l = String.valueOf(bList.get(j)) ;
set2.add(l); }
String [] vvv = intersection(set1, set2).toArray(new String[intersection(set1, set2).size()]);
String k = String.valueOf(intersection(set1, set2)); System.out.println("set1: " + set1); System.out.println("set2: " + set2);
System.out.println("Intersection: " + intersection(set1, set2));
String h = ""; int c = vvv.length; if(c==0){
sethuruf.add("*");
setangka.add(String.valueOf(densitas_b * densitas_gejala)); }
else{
String potong = (k.substring(1, k.length()-1));
sethuruf.add(potong+","); double cb = bulat((densitas_b * densitas_gejala));
(19)
}
n++; }
sethuruf.add(a); double cbb = bulat((teta_total*densitas_gejala));
setangka.add(String.valueOf(cbb)); } catch (FileNotFoundException e) {
e.printStackTrace(); } catch (IOException e) {
e.printStackTrace(); } finally {
if (br != null) { try {
br.close();
} catch (IOException e) { e.printStackTrace(); }
} }
try
{
String sFileName = folder.toString()+"/"+"irisan.csv";
FileWriter writer = new FileWriter(sFileName);
String[] huruf = sethuruf.toArray(new String[sethuruf.size()]);
String[] angka = setangka.toArray(new String[setangka.size()]);
int gg = sethuruf.size();
for(int m= 0 ; m < gg; m++){ String himp = huruf[m];
String buang_spasi = himp.replaceAll("\\s+",""); writer.append(buang_spasi);
writer.append("#"); String densi = angka[m]; writer.append(densi); writer.append("\n"); }
writer.flush(); writer.close();
(20)
}//end ststement try penulisan catch(IOException e)
{
e.printStackTrace(); }
}
//fungsi irisan
public static <T> Set<T> union(Set<T> setA, Set<T> setB) { Set<T> tmp = new TreeSet<T>(setA);
tmp.addAll(setB); return tmp;
}
public static <T> Set<T> intersection(Set<T> setA, Set<T> setB) { Set<T> tmp = new TreeSet<T>();
for (T x : setA)
if (setB.contains(x)) tmp.add(x);
return tmp; }
public static <T> Set<T> difference(Set<T> setA, Set<T> setB) { Set<T> tmp = new TreeSet<T>(setA);
tmp.removeAll(setB); return tmp;
}
public static <T> Set<T> symDifference(Set<T> setA, Set<T> setB) { Set<T> tmpA;
Set<T> tmpB;
tmpA = union(setA, setB);
tmpB = intersection(setA, setB); return difference(tmpA, tmpB); }
public static <T> boolean isSubset(Set<T> setA, Set<T> setB) { return setB.containsAll(setA);
}
public static <T> boolean isSuperset(Set<T> setA, Set<T> setB) { return setA.containsAll(setB);
}
(21)
DAFTAR RIWAYAT HIDUP
Data Pribadi
Nama
: Abdi Edhino Bangun
Tempat, Tanggal Lahir
: Medan, 10 Oktober 1990
Jenis Kelamin
: Laki-laki
Kewarganegaraan
: Indonesia
Status Perkawinan
: Belum Menikah
Tinggi dan Berat Badan
: 165 cm dan 65 kg
Agama
: Kristen Protestan
Alamat Lengkap
: Jl. Bunga Melati LK III Kemenangan Tani,
Medan
Nomor Handphone
: 087868724856
: abdi.edhino@gmail.com
Pendidikan
Formal
1995
–
1996 : TK Pardis
1996
–
2002 : SD Negeri 064023, Medan
2002
–
2005 : SMP Swasta Katolik Budi Murni-2, Medan
2005
–
2008 : SMA Negeri 17, Medan
2008
–
2012 : Diploma III ( D3 ) Manajemen Informatika STMIK Kristen
Neumann Indonesia, Medan
Non Formal
2010 : Neumann English Course, Medan
(1)
writer.flush(); writer.close();
}
catch(IOException e) {
e.printStackTrace(); }
}
private static void Teta(double teta_gejala) {
List<String> lists1 = new ArrayList<String>(); List<String> lista1 = new ArrayList<String>(); File folder = new
File(Environment.getExternalStorageDirectory() + "/ds");
String csvFile = folder.toString()+"/"+"himpunan.csv";
BufferedReader br = null; String line = "";
String cvsSplitBy = "#";
int n = 0; try {
br = new BufferedReader(new FileReader(csvFile)); while ((line = br.readLine()) != null) {
// use comma as separator
String[] himpunan = line.split(cvsSplitBy);
String str2 = himpunan[0]; //himpunan lama double densitas_b =
Double.parseDouble(himpunan[1]) ;
lists1.add(str2);
double cbt = bulat((teta_gejala * densitas_b));
lista1.add(String.valueOf(cbt));
}
} catch (FileNotFoundException e) { e.printStackTrace();
} catch (IOException e) { e.printStackTrace(); } finally {
if (br != null) { try {
br.close();
(2)
e.printStackTrace(); }
} }
try
{
String csv = folder.toString()+"/"+"teta.csv"; FileWriter writer = new FileWriter(csv); for(int m= 0 ; m <lists1.size() ; m++){
writer.append(lists1.get(m)); writer.append('#');
writer.append(lista1.get(m)); writer.append('\n');
}
writer.flush(); writer.close();
}//end ststement try penulisan catch(IOException e)
{
e.printStackTrace(); }
}
private static void Irisan(String a , double teta_gejala, double densitas_gejala ,double teta_total)
{
File folder = new
File(Environment.getExternalStorageDirectory() + "/ds");
String csvFile = folder.toString()+"/"+"himpunan.csv";
BufferedReader br = null; String line = "";
String cvsSplitBy = "#";
List<String> sethuruf = new ArrayList<String>(); List<String> setangka = new ArrayList<String>(); int n = 0;
try {
br = new BufferedReader(new FileReader(csvFile)); while ((line = br.readLine()) != null) {
// use comma as separator
String[] himpunan = line.split(cvsSplitBy); String str1 = a; // himpunan baru
(3)
String str3 = himpunan[1];
double densitas_b = 0; try{
densitas_b = Double.parseDouble(str3) ; }catch(NumberFormatException e){
throw new RuntimeException(str3 + " is not a number");
}
TreeSet<String> set1 = new TreeSet<String>(); TreeSet<String> set2 = new TreeSet<String>(); ArrayList aList= new
ArrayList(Arrays.asList(str1.split(",")));
ArrayList bList= new ArrayList(Arrays.asList(str2.split(",")));
for(int i=0;i<aList.size();i++) {
String k = String.valueOf(aList.get(i));
set1.add(k); }
for(int j=0;j<bList.size();j++) {
String l = String.valueOf(bList.get(j)) ;
set2.add(l); }
String [] vvv = intersection(set1, set2).toArray(new String[intersection(set1, set2).size()]);
String k = String.valueOf(intersection(set1, set2)); System.out.println("set1: " + set1); System.out.println("set2: " + set2);
System.out.println("Intersection: " + intersection(set1, set2));
String h = ""; int c = vvv.length; if(c==0){
sethuruf.add("*");
setangka.add(String.valueOf(densitas_b * densitas_gejala)); }
else{
String potong = (k.substring(1, k.length()-1));
sethuruf.add(potong+","); double cb = bulat((densitas_b * densitas_gejala));
(4)
}
n++; }
sethuruf.add(a); double cbb = bulat((teta_total*densitas_gejala));
setangka.add(String.valueOf(cbb)); } catch (FileNotFoundException e) {
e.printStackTrace(); } catch (IOException e) {
e.printStackTrace(); } finally {
if (br != null) { try {
br.close();
} catch (IOException e) { e.printStackTrace(); }
} }
try
{
String sFileName = folder.toString()+"/"+"irisan.csv";
FileWriter writer = new FileWriter(sFileName);
String[] huruf = sethuruf.toArray(new String[sethuruf.size()]);
String[] angka = setangka.toArray(new String[setangka.size()]);
int gg = sethuruf.size();
for(int m= 0 ; m < gg; m++){ String himp = huruf[m];
String buang_spasi = himp.replaceAll("\\s+",""); writer.append(buang_spasi);
writer.append("#"); String densi = angka[m]; writer.append(densi); writer.append("\n"); }
writer.flush(); writer.close();
(5)
}//end ststement try penulisan catch(IOException e)
{
e.printStackTrace(); }
}
//fungsi irisan
public static <T> Set<T> union(Set<T> setA, Set<T> setB) { Set<T> tmp = new TreeSet<T>(setA);
tmp.addAll(setB); return tmp;
}
public static <T> Set<T> intersection(Set<T> setA, Set<T> setB) { Set<T> tmp = new TreeSet<T>();
for (T x : setA)
if (setB.contains(x)) tmp.add(x);
return tmp; }
public static <T> Set<T> difference(Set<T> setA, Set<T> setB) { Set<T> tmp = new TreeSet<T>(setA);
tmp.removeAll(setB); return tmp;
}
public static <T> Set<T> symDifference(Set<T> setA, Set<T> setB) { Set<T> tmpA;
Set<T> tmpB;
tmpA = union(setA, setB);
tmpB = intersection(setA, setB); return difference(tmpA, tmpB); }
public static <T> boolean isSubset(Set<T> setA, Set<T> setB) { return setB.containsAll(setA);
}
public static <T> boolean isSuperset(Set<T> setA, Set<T> setB) { return setA.containsAll(setB);
}
(6)