berikut scriptnya !!!
//RH
package indomaret;
import java.util.Scanner;
public class Indomaret {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Selamat siang dan selamat berbelanja di Indomaret, berapa banyak jumlah pembelian anda? =");
int belanja = sc.nextInt();
String nama[] = new String[belanja];
int harga[] = new int[belanja];
int jumlah[] = new int[belanja];
int tot[] = new int[belanja];
int total=0;
for (int b = 0; b < belanja; b++){
System.out.print("Nama Belanja = ");
nama[b] = sc.next();
System.out.print("Harga "+nama[b]+" = ");
harga[b] = sc.nextInt();
System.out.print("Jumlah "+nama[b]+" = ");
jumlah[b] = sc.nextInt();
tot[b] = harga[b]*jumlah[b];
System.out.println("Total Bayar = "+tot[b]);
System.out.println(" ");
total=total+tot[b];}
System.out.println("Indomaret");
System.out.println(" ");
for (int c = 0; c < belanja; c++){
System.out.println("Total harga barang = "+(c+1));
System.out.println("1. Nama Barang = "+nama[c]);
System.out.println("2. Harga Barang = "+harga[c]);
System.out.println("3. Jumlah Barang = "+jumlah[c]);}
System.out.println("");
System.out.println("Total Belanjaan Seluruhnya = "+total);
System.out.println("Selamat belanja kembali");
}
}
0 komentar:
Posting Komentar