Membuat Program dijava Netbeans
Disini saya akan Membuat Program java Netbeans yaitu Program Penjualan Pheriperal
Requirement: Java
Netbeans
Komputer
yang Pertama yaitu
1.) Pilih
Pilih > File > New Project > Next > "Nama Project" > Finish
Itu tadi Adalah Codingannya.
untuk lebih jelasnya saya akan kasih Format Textnya.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package penjualan;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Reva
*/
public class Penjualan {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
String kode="";
int jumlah=0;
String cara="";
String nama="";
double harga=0;
float diskon;
int total;
System.out.println("============================");
System.out.println("Program Penjualan Pheriperal");
System.out.println("============================");
System.out.println("Daftar Harga");
System.out.println("1. Mouse Rp.350000\n1. Keyboard Rp. 2100000\n2. VGA Rp.18000000\n3. RAM Rp.500000");
BufferedReader baca=
new BufferedReader(
new InputStreamReader(System.in));
try {
System.out.println("Masukan Kode Barang :");
kode=baca.readLine();
System.out.println("Masukan Jumlah Barang :");
jumlah=Integer.valueOf(baca.readLine());
System.out.println("Masukan Cara Beli ;");
cara=baca.readLine();
} catch (IOException ex) {
Logger.getLogger(Penjualan.class.getName()).log(Level.SEVERE, null, ex);
}
if (kode.equalsIgnoreCase("mse")){
nama="Mouse";
harga=350000;
} else if (kode.equalsIgnoreCase("kyb")){
nama="Keyboard";
harga=2100000;
}else if (kode.equalsIgnoreCase("vga")){
nama="VGA";
harga=18000000;
}else{
nama="RAM";
harga=500000;
}
if (cara.equalsIgnoreCase("cash")) {
diskon=(float) (harga*0.10);
} else {
diskon=10;
}
harga=jumlah*harga;
total=(int) (harga-diskon);
System.out.println("====================");
System.out.println("Struk Pembayaran");
System.out.println("====================");
System.out.println("Kode Barang :"+kode);
System.out.println("Nama Barang :"+nama);
System.out.println("Jumlah Barang :"+jumlah);
System.out.println("Total Harga :"+harga);
System.out.println("Cara Beli : "+cara);
System.out.println("Potongan Harga : "+diskon);
System.out.println("Total Bayar :"+total);
}
}
Hasil RUN Shift + F6
Sekian Dan Terima Kasih :)