From 5757cc158873809447f5b2eaf45bac6236d9e8c3 Mon Sep 17 00:00:00 2001 From: adityamputra27 <68887223+adityamputra27@users.noreply.github.com> Date: Sun, 17 Oct 2021 06:25:26 +0700 Subject: [PATCH] Create sales application using array in c++ I've used indonesian languange in my application. --- Programs/sales-application-crud-array.cpp | 420 ++++++++++++++++++++++ 1 file changed, 420 insertions(+) create mode 100644 Programs/sales-application-crud-array.cpp diff --git a/Programs/sales-application-crud-array.cpp b/Programs/sales-application-crud-array.cpp new file mode 100644 index 0000000..cde0d10 --- /dev/null +++ b/Programs/sales-application-crud-array.cpp @@ -0,0 +1,420 @@ +#include +#include +#include +#include +#include +#include + +using namespace std; + +typedef struct { + string jenisSusu; + string ukuranSusu; + int hargaSusu; +} susu; + +susu dataSusu[9]; + +typedef struct { + string noPenjualan; + string namaCustomer; + string jenisSusu; + string ukuranSusu; + int jumlahBeli; + int hargaSusu; + double diskon; + int subTotal; + double total; +} penjualan; + +penjualan dataPenjualan[100]; +penjualan temp; + +int jumlahDataSusu = sizeof(dataSusu) / sizeof(dataSusu[0]); +int jumlahDataPenjualan; + +void menu() +{ + system("CLS"); + cout< -2; i--) + { + if(i == -1 || (a[i].jenisSusu == jenis && a[i].ukuranSusu == ukuran)) + { + return i; + } + } +} + +void inputData() +{ + system("CLS"); + char ulangi = 'y'; + int a = 0, b = 0; + int qtyPenjualan; + string jenisSusu, ukuranSusu; + double diskon; + if(jumlahDataPenjualan != 0) + { + a = jumlahDataPenjualan - 1; + } + else { + jumlahDataPenjualan = 0; + } + cout<>dataPenjualan[a].noPenjualan; + + cout<<" Masukkan Nama Customer : "; + cin>>dataPenjualan[a].namaCustomer; + + cout<<" Masukkan Jenis Susu (A - C) : "; + cin>>jenisSusu; + + jenisSusu = jenisSusu == "A" ? jenisSusu = "Dancow" : (jenisSusu == "B" ? jenisSusu = "Bendera" : (jenisSusu == "C" ? jenisSusu = "SGM" : "ERROR")); + dataPenjualan[a].jenisSusu = jenisSusu; + + cout<<" Masukkan Ukuran Kaleng (1 - 3) : "; + cin>>ukuranSusu; + + ukuranSusu = ukuranSusu == "1" ? ukuranSusu = "Kecil" : (ukuranSusu == "2" ? ukuranSusu = "Sedang" : (ukuranSusu == "3" ? ukuranSusu = "Besar" : "ERROR")); + dataPenjualan[a].ukuranSusu = ukuranSusu; + + b = search(dataSusu, jumlahDataSusu, jenisSusu, ukuranSusu); + + if(b == -1) + { + cout<<" Data Tidak Ditemukan!"<>qtyPenjualan; + dataPenjualan[a].jumlahBeli = qtyPenjualan; + + cout<= 10 && (ukuranSusu == "Besar")) + { + diskon = 0.1; + } + else if(qtyPenjualan >= 5 && (ukuranSusu == "Sedang" || ukuranSusu == "Besar")) + { + diskon = 0.05; + } + else if(qtyPenjualan >= 10 && ukuranSusu == "Kecil") + { + diskon = 0.02; + } + else + { + diskon = 0; + } + + cout<<" Diskon (%) : "<>ulangi; + cout< -2; i--) + { + if(i == -1 || a[i].noPenjualan == no) + { + return i; + } + } +} + +void cariData() +{ + system("CLS"); + string noPenjualan; + int result = 0; + char ulangi = 'y'; + + do { + cout<<" ====================================================="<>noPenjualan; + result = searchPenjualan(dataPenjualan, jumlahDataPenjualan, noPenjualan); + + if(result == -1) + { + cout<<" Data Tidak Ditemukan!"<>ulangi; + } + } while(ulangi == 'y' || ulangi == 'Y'); +} + +int sorting() +{ + for(int i = 1; i < jumlahDataPenjualan; i++) + { + for(int j = jumlahDataPenjualan - 1; j >= i; j--) + { + if(dataPenjualan[j].subTotal > dataPenjualan[j - 1].subTotal) + { + temp = dataPenjualan[j]; + dataPenjualan[j] = dataPenjualan[j - 1]; + dataPenjualan[j - 1] = temp; + } + } + } +} + +void sortingData() +{ + system("CLS"); + sorting(); + cout<>selectMenu; + + switch(selectMenu) { + case 1: + inputData(); + break; + + case 2: + tampilData(); + break; + + case 3: + cariData(); + break; + + case 4: + sortingData(); + break; + + case 5: + exportData(); + break; + + case 6: + importData(); + break; + + default: + cout<<" Pilihan Menu Tidak Ada!"<>backToMenu; + } while(backToMenu == 'y' || backToMenu == 'Y'); +}