PEMROGRAMAN CLIENT-SERVER
MAIN
package faktur;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
// TODO code application logic here
BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
costumer cos=new costumer();
System.out.println("=========================================================");
System.out.println(" FAKTUR PEMBELIAN ");
System.out.println("=========================================================");
System.out.println("\nTanggal : " + cos.getTgl());
System.out.println("Nomor : " + cos.getNomr());
System.out.println("Nama: ");
try {
cos.setNama(bfr.readLine());
//System.out.println("Nama Barang: " +brg.nambar);
} catch (Exception e) {
}
System.out.println("Alamat: ");
try {
cos.setAlamt(bfr.readLine());
//System.out.println("Nama Barang: " +brg.nambar);
} catch (Exception e) {
}
//items it=new items();
transaksi tr=new transaksi();
for(int i=1;i<=1;i++){
System.out.println("Kode barang: ");
try {
tr.setKode(bfr.readLine());
//System.out.println("Nama Barang: " +brg.nambar);
} catch (Exception e) {
}
System.out.println("Nama barang : " + tr.getNambar());
System.out.println("Harga Satuan : " + tr.hitungharga());
System.out.println("Jumlah Barang: ");
try {
} catch (Exception e) {
}
System.out.println("Total Harga : " + tr.totalharga());
}
System.out.println("Sub Jumlah : " + tr.jumlhharga(0));
System.out.println("Diskon : " + tr.diskon());
System.out.println("Total : " + tr.bayar());
}
}
Class barang
public class barang extends pembelian {
protected String kode;
protected String nambar;
protected int jml;
protected double ttal;
protected double jumharg;
protected double diskon;
protected double bayar;
protected double hrg;
public barang(int nomr, String tgl, String kode, String nambar, int jml, double ttal, double jumharg, double diskon, double bayar, double hrg) {
this.kode = kode;
this.nambar = nambar;
this.jml = jml;
this.ttal = ttal;
this.jumharg = jumharg;
this.diskon = diskon;
this.bayar = bayar;
this.hrg = hrg;
}
public barang() {
}
public double getBayar() {
return bayar;
}
public void setBayar(double bayar) {
this.bayar = bayar;
}
public double getDiskon() {
return diskon;
}
public void setDiskon(double diskon) {
this.diskon = diskon;
}
public double getJumharg() {
return (jumharg+getTtal());
}
public double getTtal() {
return (hrg*jml);
}
public void setTtal(double ttal) {
this.ttal = ttal;
}
public double getHrg() {
if (kode.equals("K001")) {
//nambar="Sound Card";
hrg=400000;
} else if (kode.equals("M001")) {
//nambar="VGA Card “ASUS”";
hrg=600000;
} else if (kode.equals("P001")) {
// nambar="Printer “EPSON”";
hrg=500000;
}
return hrg;
}
public void setHrg(double hrg) {
this.hrg = hrg;
}
public int getJml() {
return jml;
}
public void setJml(int jml) {
this.jml = jml;
}
public String getKode() {
return kode;
}
public void setKode(String kode) {
this.kode = kode;
}
public String getNambar() {
if (kode.equals("K001")) {
nambar="Sound Card";
// harga=400000;
} else if (kode.equals("M001")) {
nambar="VGA Card “ASUS”";
//harga=600000;
} else if (kode.equals("P001")) {
nambar="Printer “EPSON”";
//harga=500000;
}
return nambar;
}
public void setNambar(String nambar) {
this.nambar = nambar;
}
// public void JUMLAH(){
// jumharg=jumharg+getTtal();
//}
}
Class customer
public class costumer extends pembelian{
protected String nama;
protected String alamt;
public costumer(int nomr, String tgl, String nama, String alamt) {
super(nomr,tgl);
this.nama = nama;
this.alamt = alamt;
}
public costumer() {
}
public String getAlamt() {
return alamt;
}
public void setAlamt(String alamt) {
this.alamt = alamt;
}
public String getNama() {
return nama;
}
public void setNama(String nama) {
this.nama = nama;
}
}
Class item
public class item extends pembelian{
protected String kode;
protected String nambar;
protected double harga;
public item(int nomr, String tgl, String kode, String nambar, double harga) {
super(nomr,tgl);
this.kode = kode;
this.nambar = nambar;
this.harga = harga;
}
public item() {
}
public String getKode() {
return kode;
}
public void setKode(String kode) {
this.kode = kode;
}
public String getNambar() {
if (kode.equals("K001")) {
nambar="Sound Card";
// harga=400000;
} else if (kode.equals("H001")) {
nambar="hardisk 360 GB";
//harga=600000;
} else if (kode.equals("P001")) {
nambar="Printer “EPSON”";
//harga=500000;
}
return nambar;
}
public void setNambar(String nambar) {
this.nambar = nambar;
}
public double hitungharga(){
if (kode.equals("K001")) {
//nambar="Sound Card";
harga=400000;
} else if (kode.equals("H001")) {
//nambar="VGA Card “ASUS”";
harga=600000;
} else if (kode.equals("P001")) {
// nambar="Printer “EPSON”";
harga=500000;
}
return (harga);
}
}
Class pembelian
public class pembelian {
protected int nomr;
protected String tgl;
public pembelian(int nomr, String tgl) {
this.nomr = nomr;
this.tgl = tgl;
}
public pembelian() {
setNomr(1196);
setTgl("21 November 2011");
}
public int getNomr() {
return nomr;
}
public void setNomr(int nomr) {
this.nomr = nomr;
}
public String getTgl() {
return tgl;
}
public void setTgl(String tgl) {
this.tgl = tgl;
}
}
Class pembelian
package faktur;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class pembeliannya {
public static void main(String[] args) {
// TODO code application logic here
BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
costumer cos=new costumer();
System.out.println("==========================================================");
System.out.println(" FAKTUR PEMBELIAN ");
System.out.println("==========================================================");
System.out.println("\nTanggal : " + cos.getTgl());
System.out.println("Nomor : " + cos.getNomr());
System.out.println("Kepada: ");
try {
cos.setNama(bfr.readLine());
//System.out.println("Nama Barang: " +brg.nambar);
} catch (Exception e) {
}
System.out.println("Alamat: ");
try {
cos.setAlamt(bfr.readLine());
//System.out.println("Nama Barang: " +brg.nambar);
} catch (Exception e) {
}
barang brg=new barang();
for(int i=1;i<=2;i++){
System.out.println("Kode barang: ");
try {
brg.setKode(bfr.readLine());
//System.out.println("Nama Barang: " +brg.nambar);
} catch (Exception e) {
}
System.out.println("Nama barang : " + brg.getNambar());
System.out.println("Harga Satuan : " + brg.getHrg());
System.out.println("Jumlah Barang: ");
try {
brg.setJml(Integer.valueOf(bfr.readLine()));
} catch (Exception e) {
}
System.out.println("Total Harga : " + brg.getTtal());
}
System.out.println("Jumlah Harga : " + brg.getJumharg());
//System.out.println("Diskon : " + tr.diskon());
//System.out.println("Jumlah Bayar : " + tr.bayar());
}
}
Class transaksi
public class transaksi extends item {
protected double jml;
public transaksi(int nomr, String tgl, String kode, String nambar, double harga, double jml) {
super(nomr,tgl,kode,nambar,harga);
this.jml = jml;
}
public transaksi() {
}
public double getJml() {
return jml;
}
public void setJml(double jml) {
this.jml = jml;
}
public double totalharga(){
return (super.hitungharga()*jml);
}
public double jumlhharga(double juml){
return (juml+totalharga());
}
public double diskon(){
return Math.floor(jumlhharga(jml)*5/100);
}
public double bayar(){
return (jumlhharga(jml)-diskon());
}
}
OUTPUT
Anda baru saja membaca artikel yang berkategori Client Server
dengan judul PROGRAM PEMBELIAN MENGGUNAKAN NET-BEN. Anda bisa bookmark halaman ini dengan URL https://belajar-dgn-vb.blogspot.com/2012/06/program-pembelian-menggunakan-net-ben.html. Terima kasih!
Ditulis oleh:
Unknown - Friday, 29 June 2012
Belum ada komentar untuk "PROGRAM PEMBELIAN MENGGUNAKAN NET-BEN"
Post a Comment