package
tugas5;
import
java.util.Scanner;
public
class Tugas5 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("Jumlah barang
yang dibeli : ");
int pilihan= s.nextInt();
String nama[]=new String[pilihan];
int harga[]=new int[pilihan];
int jumlah[]=new int [pilihan];
int total[]=new int[pilihan];
int tot=0;
for (int a=0;a<pilihan;a++){
System.out.print("Nama barang
ke- "+(a+1)+" = ");
nama[a]=s.next();
System.out.print("Harga
"+nama[a]+" = ");
harga[a]=s.nextInt();
System.out.print("Jumlah
"+nama[a]+" = ");
jumlah[a]=s.nextInt();
total[a]=jumlah[a]*harga[a];
System.out.print("Total harga
= "+total[a]);
tot=tot+total[a];
System.out.println();
}
{
System.out.println("****************************************"
+ "*************************************************");
}
for (int a=0; a<pilihan;a++)
{
System.out.println("Nama Barang
"+ (a+1)+" : " +nama[a]+"\t jumlah : "+jumlah[a]
+" \t Harga : Rp "+harga[a]+" \t Total Harga : Rp
"+total[a]);
}
{
System.out.println ("Total
Belanja = Rp "+tot);
}
}
}
Output yang dihasilkan