mungkin tulisan ini agak penting buat temen-temen yang lagi mengambil praktikum pemrograman Java atau mau ngambil, jadi…. jangan hanya di co-past oke coba dulu jalan pa gak, makanya aku gak nampilkan hasil runningnya….
sory yaaa……..
Modul 1
Praktikum :
1.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package VadSoft.PraktikumJava.Modul1;/**
*
* @author zabrina
*/
public class Relational {
public static void main(String[] md1a) {
int x = 7;
int y = 11;
int z = 11;
System.out.println((“x : ” + x));
System.out.println(“y : ” + y);
System.out.println(“z : ” + z);
System.out.println(“x < y : ” + (x < y));
System.out.println(“x > z : ” + (x > z));
System.out.println(“x <= z : ” + (x <= z));
System.out.println(“x >= y : ” + (x >= y));
System.out.println(“y == z : ” + (y == z));
System.out.println(“x != y : ” + (x != y));
}
}2.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package VadSoft.PraktikumJava.Modul1;/**
*
* @author zabrina
*/
public class Conditional {
public static void main(String []md1b) {
int x = 0;
boolean isEven = false;
System.out.println(“x = ” + x);
x = isEven ? 4 : 7;
System.out.println(“x=” + x);
}
}
3.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package VadSoft.PraktikumJava.Modul1;/**
*
* @author zabrina
*/
public class TMP03A {
public static void main(String[] md1c) {
int[] a = new int[md1c.length];
for (int i = 0; i < md1c.length; i++) {
a[i] = Integer.parseInt(md1c[i]);
}
if (a[0] > a[1]) {
System.out.println(“Jumlah :” + (a[0] + a[1]));
} else if (a[0] < a[1]) {
System.out.println(“Kali :” + (a[0] * a[1]));
} else {
System.out.println(“Kedua Bilangan Sama :” + a[0]);
}
}
}
4.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package VadSoft.PraktikumJava.Modul1;/**
*
* @author zabrina
*/
public class Faktorial {
public static void main(String[] md14) {
int h = 1;
for (int i = 1; i <= 10; i++) {
h = i * h;
System.out.println(i + “! = ” + h);
}
}
}
Tugas Praktikum
1.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package VadSoft.PraktikumJava.Modul1;/**
*
* @author zabrina
*/
public class operasiLogika {
public static void main(String []md15) {
boolean a = false;
boolean b = false;
boolean opAnd, opOr, opNand, opNor, opXor;
System.out.println(“A\tB\tAND\tOR\tNAND\tNOR\tXOR”);
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
opAnd = a & b;
opOr = a | b;
opNand = !(a & b);
opNor = !(a | b);
opXor = a ^ b;
System.out.println(a + “\t” + b + “\t” + opAnd + “\t” + opOr + “\t” + opNand + “\t” + opNor + “\t” + opXor);
b = !b;
}
a = !a;
}
}
}
2.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package VadSoft.PraktikumJava.Modul1;/**
*
* @author zabrina
*/
public class operasiLogika {
public static void main(String []md15) {
boolean a = false;
boolean b = false;
boolean opAnd, opOr, opNand, opNor, opXor;
System.out.println(“A\tB\tAND\tOR\tNAND\tNOR\tXOR”);
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
opAnd = a & b;
opOr = a | b;
opNand = !(a & b);
opNor = !(a | b);
opXor = a ^ b;
System.out.println(a + “\t” + b + “\t” + opAnd + “\t” + opOr + “\t” + opNand + “\t” + opNor + “\t” + opXor);
b = !b;
}
a = !a;
}
}
}
3.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package VadSoft.PraktikumJava.Modul1;/**
*
* @author zabrina
*/
public class faktorialRekursif {
public static void main(String[] md17) {
faktorialRekursif FR = new faktorialRekursif();
for (int i = 1; i <= 10; i++) {
System.out.println(i + “! = ” + FR.faktorialRek(i));
}
}
private int faktorialRek(int a) {
if (a > 1) {
a *= faktorialRek(a – 1);
} else {
a = 1;
}
return a;
}
}
Lha aku iki wong Jowo…………………..!!!!!!

