-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStruct UDT kasir2.cpp
More file actions
56 lines (43 loc) · 1.47 KB
/
Copy pathStruct UDT kasir2.cpp
File metadata and controls
56 lines (43 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <string.h>
#include <iomanip>
using namespace std;
struct DataBarang
{
int jum_beli, jumlah[50], harga[50];
string nama_barang[50];
};
DataBarang Brg[50];
int main() {
int bayar, sub_tot[50];
float tot;
cout << "PROGRAM C++ KASIR" << endl;
cout << "---------------------------" << endl;
cout << endl;
cout << "Masukan Jumlah Beli : ";
cin >> Brg[50].jum_beli;
for (int i = 0; i < Brg[50].jum_beli; i++) {
cout << endl;
cout << "Masukan Barang Ke-" << i + 1 << endl;
cout << "Nama Barang : ";cin >> Brg[i].nama_barang[i];
cout << "Jumlah : ";cin >> Brg[i].jumlah[i];
cout << "Harga : ";cin >> Brg[i].harga[i];
sub_tot[i] = Brg[i].jumlah[i] * Brg[i].harga[i];
tot += sub_tot[i];
}
cout << endl;
cout << "STRUK BELANJA MINI MARKET BABE" << endl;
cout << "---------------------------------------------------------" << endl;
cout << "No Barang Jumlah Harga Sub Total" << endl;
for (int i = 0; i < Brg[50].jum_beli; i++) {
cout << i + 1 << setw(8) << Brg[i].nama_barang[i] << setw(10) << Brg[i].jumlah[i] << setw(12) << Brg[i].harga[i] << setw(12) << sub_tot[i] << endl;
}
cout << endl;
cout << "--------------------------------------------------------\n";
cout << "Jumlah Bayar : Rp." << tot << endl;
cout << "Bayar : Rp.";
cin >> bayar;
cout << "Kembali : Rp." << bayar - tot << endl;
system("pause");
return 0;
}