Th3den’s Weblog

Blog for All

Tugas matematika diskrit

Posted by th3den on November 16, 2008

hai temen2
ni aku dah dapet source code tugas matematika diskrit silakan dicopy ndiri yah

/*———————————————————————————–
* madis.java
*
*
*/

/**
*
* @author 1381
*/
import javax.swing.*;

public class madis2 extends javax.swing.JFrame {

/** Creates new form madis */
public madis2() {
initComponents();
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
him1 = new javax.swing.JTextField();
him2 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
ekiv = new javax.swing.JTextArea();
iris = new javax.swing.JTextArea();
jLabel5 = new javax.swing.JLabel();
uni = new javax.swing.JTextArea();
Reset = new javax.swing.JButton();
ok = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
kali = new javax.swing.JTextArea();
jLabel6 = new javax.swing.JLabel();
jTextArea2 = new javax.swing.JTextArea();

getContentPane().setLayout(null);

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle(” .: Himpunan Matematika Diskrit :.”);
setBackground(new java.awt.Color(255, 0, 0));
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
setResizable(false);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});

jLabel1.setText(“Himpunan 1”);
getContentPane().add(jLabel1);
jLabel1.setBounds(20, 20, 90, 20);

jLabel2.setText(“Himpunan 2”);
getContentPane().add(jLabel2);
jLabel2.setBounds(20, 50, 80, 20);

getContentPane().add(him1);
him1.setBounds(90, 20, 130, 20);

getContentPane().add(him2);
him2.setBounds(90, 50, 130, 19);

jLabel3.setText(“Ekivalen”);
getContentPane().add(jLabel3);
jLabel3.setBounds(40, 140, 80, 30);

jLabel4.setText(“Irisan”);
getContentPane().add(jLabel4);
jLabel4.setBounds(40, 300, 60, 20);

ekiv.setColumns(20);
ekiv.setEditable(false);
ekiv.setRows(5);
getContentPane().add(ekiv);
ekiv.setBounds(10, 170, 350, 120);

iris.setColumns(20);
iris.setEditable(false);
iris.setRows(5);
getContentPane().add(iris);
iris.setBounds(10, 322, 350, 130);

jLabel5.setText(“Union”);
getContentPane().add(jLabel5);
jLabel5.setBounds(40, 460, 60, 20);

uni.setColumns(20);
uni.setEditable(false);
uni.setRows(5);
getContentPane().add(uni);
uni.setBounds(10, 490, 350, 120);

Reset.setMnemonic(‘r’);
Reset.setText(“Reset”);
Reset.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ResetActionPerformed(evt);
}
});

getContentPane().add(Reset);
Reset.setBounds(20, 90, 70, 23);

ok.setMnemonic(‘o’);
ok.setText(“OK”);
ok.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okActionPerformed(evt);
}
});

getContentPane().add(ok);
ok.setBounds(130, 90, 60, 23);

kali.setColumns(20);
kali.setEditable(false);
kali.setRows(5);
jScrollPane1.setViewportView(kali);

getContentPane().add(jScrollPane1);
jScrollPane1.setBounds(370, 170, 250, 440);

jLabel6.setText(“Perkalian Kartesian”);
getContentPane().add(jLabel6);
jLabel6.setBounds(390, 140, 130, 30);

jTextArea2.setColumns(20);
jTextArea2.setEditable(false);
jTextArea2.setLineWrap(true);
jTextArea2.setRows(5);
jTextArea2.setText(“nama : th deny w\nnim : 07.11.1381”);
getContentPane().add(jTextArea2);
jTextArea2.setBounds(240, 20, 160, 40);

java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width-644)/2, (screenSize.height-656)/2, 644, 656);
}// //GEN-END:initComponents

private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed
//ekivalen
tampil = “”;
bil1 = him1.getText();
bil2 = him2.getText();
tampil += “Banyak Himpunan Pertama : “+bil1.length();
tampil += “\nBanyak Himpuanan Kedua : “+bil2.length();
if(bil1.length() == bil2.length()) {
tampil += “\nP.Himpunan Pertama ~ P.Himpunan Kedua : “+bil1.length()+” , “+bil2.length();
tampil += “\nP.Himpunan Pertama = P.Himpunan Kedua”;
}
else {
tampil += “\nP.Himpunan Pertama ~ P.Himpunan Kedua : “+bil1.length()+” , “+bil2.length();
tampil += “\nP.Himpunan Pertama != P.Himpunan Kedua”;
}
ekiv.setText(tampil);
tampil = “”;

//irisan
tampil = “”;
bil1 = him1.getText();
bil2 = him2.getText();
for(int i=0; i<bil1.length(); i++){
int bantu = bil1.charAt(i);
iris(bantu);
}
iris.setText(“Himpunan 1 [ “+bil1+” ]”+
“\nHimpunan 2 [ “+bil2+” ]”+
“\n\nHasil Irisan = “+tampil);
tamIr = tampil;
bantu2 = tampil;
tampil = “”;
help = “”;
post =””;
ac = “”;

//union
tampil = “”;
bil1 = him1.getText();
bil2 = him2.getText();
for(int j=0; j<bil1.length(); j++) {
iris(bil1.charAt(j));
}
union();
uni.setText(“Himpunan 1 [ “+bil1+” ]”+
“\nHimpunan 2 [ “+bil2+” ]”+
“\n\nHasil Union = “+tampil);
tamUni = tampil;
bantuan = tampil;
tampil = “”;
help=””;
post =””;
ac = “”;

//cek
int a = bil1.length();
int b = bil2.length();
cekIrisan(a, b, bil1, bil2);
cekUnion(a, b, bil1, bil2);

//perkalian
tampil = “”;
bil1 = him1.getText();
bil2 = him2.getText();
for(int i=0; i bil2) {
for(int i=0; i<tamUni.length(); i++) {
cek(tamUni.charAt(i), i+1);
}
tamUni = ac;
uni.setText(“Himpunan 1 [ “+a+” ]”+
“\nHimpunan 2 [ “+b+” ]”+
“\n\nHasil Union = “+tamUni);
}
else if(bil1 == bil2) {
for(int k=0; k<bil1; k++) {
for(int i=0; i<tamUni.length(); i++) {
cek(tamUni.charAt(i), i+1);
}
tamUni = ac;
uni.setText(“Himpunan 1 [ “+a+” ]”+
“\nHimpunan 2 [ “+b+” ]”+
“\n\nHasil Union = “+tamUni);
}
}
else if(bil1 < bil2) {
for(int k=0; k<bil2; k++) {
for(int i=0; i bil2) {
for(int k=0; k<bil1; k++) {
//irisan
for(int i=0; i<tamIr.length(); i++) {
cek2(tamIr.charAt(i), i+1);
}
tamIr = ac;
iris.setText(“Himpunan 1 [ “+a+” ]”+
“\nHimpunan 2 [ “+b+” ]”+
“\n\nHasil Irisan = “+tamIr);
}
}
else if(bil1 == bil2) {
for(int k=0; k<bil1; k++) {
//irisan
for(int i=0; i<tamIr.length(); i++) {
cek2(tamIr.charAt(i), i+1);
}
tamIr = ac;
iris.setText(“Himpunan 1 [ “+a+” ]”+
“\nHimpunan 2 [ “+b+” ]”+
“\n\nHasil Irisan = “+tamIr);
}
}
else if(bil1 < bil2) {
for(int k=0; k<bil2; k++) {
//irisan
for(int i=0; i<tamIr.length(); i++) {
cek2(tamIr.charAt(i), i+1);
}
tamIr = ac;
iris.setText(“Himpunan 1 [ “+a+” ]”+
“\nHimpunan 2 [ “+b+” ]”+
“\n\nHasil Irisan = “+tamIr);
}
}
}

//irisan
public static void iris(int a) {
for(int i=0; i<bil2.length(); i++){
if(bil2.charAt(i) == a) {
tampil +=””+bil2.charAt(i)+””;
}
}
}

//union
public static void union() {
String bantu = tampil;
tampil = “”;

help = bil1;
for(int i=0; i<bantu.length(); i++) {
buangBil(bantu.charAt(i));
}

String babil1 = help;
help = bil2;
for(int i=0; i<bantu.length(); i++) {
buangBil(bantu.charAt(i));
}
String babil2 = help;
help = “”;
tampil = babil1+bantu+babil2;
}

//buang char
public static void buangBil(int c) {
for(int i=0; i<help.length(); i++){
if(help.charAt(i) == c) {
help = hapusBilangan(help, i);
}
}
}

//perkalian
public static void kali(String c) {
String a = “”;
String b = “”;

int bts = bil2.length();
for(int i=0; i<bts; i++) {
try {
int bantu = 0;
for(int j=0; j<bil2.length(); j++) {
a = c;
b = “”+bil2.charAt(j);
int b1 = Integer.parseInt(c);
int b2 = Integer.parseInt(“”+bil2.charAt(j));

int kl = b1*b2;
tampil += “\n”+c+” * “+b2+” = “+kl;
bantu += kl;
}
hitKal += bantu;
}
catch (Exception e) {
tampil += “\n”+a+” * “+b+” = “+a+””+b;
}
}
}

//buang char 2
public static void cek(char a, int b) {
for(int j=b; j<bantuan.length(); j++) {
if(bantuan.charAt(j) == a) {
ac = bantuan.substring(0,j) + bantuan.substring(j+1);
bantuan=ac;
}
ac = bantuan;
}
}

//buang char 3
public static void cek2(char a, int b) {
for(int j=b; j<bantu2.length(); j++) {
if(bantu2.charAt(j) == a) {
ac = bantu2.substring(0,j) + bantu2.substring(j+1);
bantu2=ac;
}
ac = bantu2;
}
}

//remove char 1
public static String hapusBilangan(String s, int pos) {
return s.substring(0,pos)+s.substring(pos+1);
}

public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
//@Override
public void run() {
new madis2().setVisible(true);
}
});
}

// Variables declaration – do not modify//GEN-BEGIN:variables
private javax.swing.JButton Reset;
private javax.swing.JTextArea ekiv;
private javax.swing.JTextField him1;
private javax.swing.JTextField him2;
private javax.swing.JTextArea iris;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea2;
private javax.swing.JTextArea kali;
private javax.swing.JButton ok;
private javax.swing.JTextArea uni;
// End of variables declaration//GEN-END:variables
static String bil1 ;
static String bil2 ;
static String tampil = “”;
static String help = “”;
static int hitKal = 0;
static String tmp = “”;
static boolean er = false;
static String post=””;
static String ac=””;
static String tamIr = “”;
static String tamUni = “”;
static String bantuan = “”;
static String bantu2 = “”;
}
//————————————————————————————

jangan lupa diSave as dengan nama “madis2.java”
trus copy..
——————————copy bawah————————————–

——————————–save as———————–

save as madis2.form
tarus di satu folder sama madis2.java

buka pake netbean ya caranya pilih file, terus open file, pilih madis2.form
nah baru dimodifikasi disithu…..

kalo udah compile pake perintah javac madis2.java

thanks buat didi cyber yang udah share sourcenya
http://www.didicyber.co.cc

download ke sini

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: