melakukan inputan dari keyboard dengan java.
berikut source code nya :
/*
* 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 praktikum4;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/**
*
* @author H4nk
*/
public class inputdarikeyboard3 {
public static void main(String[]args){
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
String nofak="";
String napel="";
String jumdata="";
try {
System.out.println(" Input Data Penjualan ");
System.out.println("============================================");
System.out.print("No. Faktur :");
nofak = input.readLine();
System.out.print("Nama Pelanggan :");
napel = input.readLine();
System.out.print("Jumlah beli :");
jumdata = input.readLine();
}catch(Exception e){
System.out.println("Ada Kesalahan....!");
}
int jb= Integer.valueOf(jumdata).intValue();
String kobar[] = new String[jb];
String nabar[] = new String[jb];
String harga[] = new String[jb];
String qty[] = new String[jb];
double jmlharga[] = new double[jb];
double totsel=0;
double ppn=0;
double totbay=0;
System.out.println("=====================Input Data Barang=============");
for(int i=0; i<jb; i++)
{
try{
System.out.println("Data ke " +(i+1));
System.out.print("Kode Barang : ");
kobar[i] = input.readLine();
System.out.print("Nama Barang : ");
nabar[i]= input.readLine();
System.out.print("Harga : ");
harga[i] = input.readLine();
System.out.print("Qty :");
qty[i] = input.readLine();
double hrg = Double.valueOf(harga[i]).doubleValue();
int qt = Integer.valueOf(qty[i]).intValue();
jmlharga[i] = hrg * qt;
totsel = totsel + jmlharga[i];
ppn = 0.1 * totsel;
totbay = totsel + ppn;
}catch(Exception e){
System.out.println("Ada Kesalahan....!");
}
}
System.out.println("============TOKO AL RASYID=========================");
System.out.println("================FAKTUR PENJUALAN===================");
System.out.println("No Faktur :"+nofak);
System.out.println("Nama Pelanggan :"+napel);
System.out.println("==================================================================");
System.out.println("No. Kode Barang Nama Barang harga Qty Jumlah Harga");
System.out.println("==================================================================");
for (int i=0;i<jb;i++){
System.out.println((i+1)+"\t"+kobar[i]+"\t\t"+ nabar[i]+"\t\t"+harga[i]+"\t"+qty[i]+"\t"+jmlharga[i]);
}
System.out.println("===================================================================");
System.out.println("Total :"+"\t\t\t\t\t\t"+totsel);
System.out.println("Ppn(10%) :"+"\t\t\t\t\t\t"+ppn);
System.out.println("Total Bayar :"+"\t\t\t\t\t\t"+totbay);
System.out.println("===================================================================");
}
}
hasil dari debug file tersebut adalah seperti pada gambar di bawah ini:
Tidak ada komentar:
Posting Komentar