import java.io.*;
public class java{
public static void main(String[] args){
try{
BufferedReader x=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Masukan jumlah data : ");
int n=Integer.parseInt(x.readLine());
String []nama =new String[n];
int []harga=new int[n];
int []quantiti=new int[n];
int []jumlah=new int[n];
int []jumlah2=new int[n];
int []diskon=new int[n];
int i,total=0;
for (i=0;i<n;i++) {
BufferedReader nb=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Masukan Nama Barang : ");
nama[i]=nb.readLine();
BufferedReader hb=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Masukan Harga Barang : ");
harga[i]=Integer.parseInt(hb.readLine());
BufferedReader jb=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Masukan Jumlah Barang : ");
quantiti[i]=Integer.parseInt(jb.readLine());
jumlah[i]=harga[i]*quantiti[i];
diskon[i]=0;
if (jumlah[i]>=100000){
diskon[i]=jumlah[i]/10;
}
jumlah2[i]=jumlah[i]-diskon[i];
total=total+jumlah2[i];
}
System.out.println();
System.out.println();
System.out.println("No|Nama Barang|Harga Barang|Jumlah Barang|Jumlah Harga| Diskon | Total");
for (i=0;i<n;i++){
System.out.println(++i+" | "+nama[--i]+" | "+harga[i]+" | "+quantiti[i]+" | "+jumlah[i]+" | "+diskon[i]+" | "+jumlah2[i]);
}
System.out.println();
System.out.println("Total Harga yang Harus Anda Bayar : "+total);
}
catch (IOException e){
e.printStackTrace();
}
}
}
Categories:
java