~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~SAYA MENDENGAR LALU SAYA LUPA ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SAYA MEMBACA LALU SAYA INGAT ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SAYA MELAKUKAN LALU SAYA MENGERTI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

27 May 2016

PROGRAM KASIR DENGAN C++


Program kasir C++

       Program kasir ini saya buat dengan software Dev C++.  Program kasir ini mungkin bisa dibuat untuk bahan referensi dalam 'belajar'  bahasa C++. Fitur atau algoritma dalam program ini menyangkut beberapa hal berikut :

  • Validasi
  • Pilih barang sesuai yang ada.
  • Masukkan jumlah barang.
  • Menambah barang selama masih ada barang yang ingin dibeli.
  • Struk belanja yang terdiri dari nama barang, harga satuan, jumlah, subtotal harga, dan total harga.
  • Input Pembayaran dan validasi input pembayaran salah jika nominal uang tidak wajar seperti Rp. 1010 atau 1050, karena uang Rp 50 kemungkinan sudah tidak dipakai menurut saya.
  • Tampilkan kembalian jika ada.
  • Saran kembalian.
  • Kekurangan Pembayaran.
  • Mengulang Program.

Supaya lebih jelas, silahkan lihat dulu file exe nya. Download di bawah ini :


Untuk source code nya. bisa dilihat di bawah ini. Untuk maksut dari setiap perintah/kode jika belum mengerti, silahkan cari sendiri di google. Dan karena program ini hasil buatan saya oleh karena itu jika ada kekurangan dalam pemrograman ini mohon dimaafkan.  


#include <iostream>
#include <string>
#include <sstream>
#include <windows.h>

/**
PROGRAM KASIR C++
alfiansyahmaulana.blogspot.co.id
*/

using namespace std;

void gotoxy(int x, int y)
 {
  COORD coord;
  coord.X = x;
  coord.Y = y;
  SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
 }

void setcolor(unsigned short color)
 {
  HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
  SetConsoleTextAttribute(hCon, color);
 }

int main()
{
 
 awalprogram:
 
 system("CLS"); 
 
 string line, tampilbarang[1000], nambah;
 int i, j, jenisbarang, jumlahbarang[1000], total[1000], totalharga, kembalian, bayar, harga[1000];
 
 string t="t";
 string T="T"; 
 string y="y";
 string Y="Y";
 
 totalharga=0;
 
 setcolor(271);  gotoxy(10, 0); cout << "PROGRAM KASIR DENGAN C++ | www.alfiansyahmaulana.blogspot.co.id" << endl << endl;
 
 setcolor(10);
 cout << "DAFTAR BARANG YANG DIJUAL : "<< endl;
 cout << "--------------------------------------------------------------" << endl;
 cout << "| 1.  Buku Tulis\t";   cout << "| 6.  Spidol\t\t" << endl;   
 cout << "| 2.  Pensil\t\t";   cout << "| 7.  Rautan\t\t" << endl;   
 cout << "| 3.  Bolpoint\t\t";   cout << "| 8.  Gunting\t\t" << endl;   
 cout << "| 4.  Penggaris\t\t";   cout << "| 9.  Buku Gambar\t" << endl;   
 cout << "| 5.  Penghapus\t\t";   cout << "| 10. Sampul Buku\t" << endl << endl;  

 cout << "| 11. Lem\t\t";    cout << "| 16. DVD Blank" << endl;
 cout << "| 12. Isolasi\t\t";  cout << "| 17. Map" << endl;
 cout << "| 13. Kertas Karton\t";  cout << "| 18. Penjepit Kertas" << endl;
 cout << "| 14. Kertas Bufalo\t";  cout << "| 19. Kertas Mika" << endl;
 cout << "| 15. CD Blank\t\t";   cout << "| 20. Permen" << endl;
 cout << "--------------------------------------------------------------"<< endl << endl << endl;

/**
PROGRAM KASIR C++
alfiansyahmaulana.blogspot.co.id
*/
   
  nambah=y;
 
 for (i=1; nambah == y || nambah == Y; i++)
 {
  salah:
     
  setcolor(14); gotoxy (0, 17); cout << "Pilih Jenis Barang : ";
  
  while (getline(cin, line))
     {
         stringstream ss(line);
         if (ss >> jenisbarang)
         {
             if (ss.eof())
             {   
                 break;
             }
         }
         gotoxy (0, 17);  setcolor(256);  cout << "                                                                                                                                                                                                               ";
         gotoxy (0, 18);  setcolor(252);  cout << " MASUKKAN SALAH !! " << endl;
         gotoxy (0, 17);  setcolor(14);  cout << "Pilih Jenis Barang : ";
  } 

 switch (jenisbarang)
 {
  case 1:
   tampilbarang[i]="Buku Tulis";
   goto a;
   break;
  case 2:
   tampilbarang[i]="Pensil";
   goto a;
   break;
  case 3:
   tampilbarang[i]="Bolpoint";
   goto a;
   break;
  case 4:
   tampilbarang[i]="Penggaris";
   goto a;
   break;
  case 5:
   tampilbarang[i]="Penghapus";
   goto a;
   break;
  case 6:
   tampilbarang[i]="Spidol";
   goto a;
   break;
  case 7:
   tampilbarang[i]="Rautan";
   goto a;
   break;
  case 8:
   tampilbarang[i]="Gunting";
   goto a;
   break;
  case 9:
   tampilbarang[i]="Buku Gambar";
   goto a;
   break;
  case 10:
   tampilbarang[i]="Sampul Buku";
   goto a;
   break;
  case 11:
   tampilbarang[i]="Lem";
   goto a;
   break;
  case 12:
   tampilbarang[i]="Isolasi";
   goto a;
   break;
  case 13:
   tampilbarang[i]="Kertas Karton";
   goto a;
   break;
  case 14:
   tampilbarang[i]="Kertas Buffalo";
   goto a;
   break;
  case 15:
   tampilbarang[i]="CD Blank";
   goto a;
   break;
  case 16:
   tampilbarang[i]="DVD Blank";
   goto a;
   break;
  case 17:
   tampilbarang[i]="Map";
   goto a;
   break;
  case 18:
   tampilbarang[i]="Penjepit Kertas";
   goto a;
   break;
  case 19:
   tampilbarang[i]="Kertas Mika";
   goto a;
   break;
  case 20:
   tampilbarang[i]="Permen";
   goto a;
   break;
  
  default:
  setcolor(256); gotoxy (0, 17); cout << "                                                                                                                                                                                                               " << endl;  
  setcolor(252);
        gotoxy (0, 18); cout << " PILIHAN TIDAK ADA !! " << endl;
  goto salah;     
 }

 a: 
 
 setcolor(256);  gotoxy (0, 18); cout << "                              ";
 setcolor(14);  gotoxy (0, 20); cout << "Masukkan Jumlah " << tampilbarang[i] <<" : ";
  
  while (getline(cin, line))
     {
         stringstream ss(line);
         if (ss >> jumlahbarang[i])
         {
             if (ss.eof())
             {   
                 break;
             }
         }
         setcolor(256);  gotoxy (0, 20); cout << "                                                                                                                                                                                                               " << endl;
         setcolor(252);  gotoxy (0, 21); cout << " MASUKKAN SALAH !! " << endl;
         setcolor(14); gotoxy (0, 20); cout << "Masukkan Jumlah " << tampilbarang[i] <<" : ";
  }  
 
 switch (jenisbarang)
 {
  case 1:
   harga[i]=3000;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 2:
   harga[i]=1000;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 3:
   harga[i]=2000;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 4:
   harga[i]=2500;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 5:
   harga[i]=1000;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 6:
   harga[i]=2000;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 7:
   harga[i]=1000;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 8:
   harga[i]=6000;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 9:
   harga[i]=4000;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 10:
   harga[i]=250;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 11:
   harga[i]=2000;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 12:
   harga[i]=4000;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 13:
   harga[i]=2000;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 14:
   harga[i]=500;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 15:
   harga[i]=3000;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 16:
   harga[i]=5000;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 17:
   harga[i]=500;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 18:
   harga[i]=3000;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 19:
   harga[i]=500;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  case 20:
   harga[i]=100;
   total[i]=jumlahbarang[i]*harga[i];
   break;
  
  default:
  setcolor(252);
        gotoxy (0, 18); cout << " PILIHAN TIDAK ADA !! " << endl;
  goto salah;     
 }

 setcolor(256);  gotoxy (0, 18);  cout << "                       " << endl;
     gotoxy (0, 21);  cout << "                       " << endl;
 
 totalharga=totalharga+total[i];
 
 
 setcolor(14); gotoxy (0, 23); cout << "Apakah ingin tambah barang ?(y/t) : ";
 getline(cin, nambah);
 
 while (nambah != y && nambah != Y && nambah != t && nambah != T)
 { 
  setcolor(256);  gotoxy (0, 23);  cout << "                                                                                                                                                                                                               " << endl;   
  setcolor(252); gotoxy (0, 24);  cout << " KETIKKAN Y UNTUK MENAMBAH BARANG ATAU T UNTUK SELESAI MENAMBAH BARANG !! "; 
  setcolor(14); gotoxy (0, 23);  cout << "Apakah ingin tambah barang ?(y/t) : ";
  getline(cin, nambah);
 }
 
 if (nambah == t || nambah == T)
 {
  goto uwes;
 }
 
 system("cls");
 
 setcolor(271);  gotoxy(10, 0); cout << "PROGRAM KASIR DENGAN C++ | www.alfiansyahmaulana.blogspot.co.id" << endl << endl;
 
 setcolor(10);
 cout << "DAFTAR BARANG YANG DIJUAL : "<< endl;
 cout << "--------------------------------------------------------------" << endl;
 cout << "| 1.  Buku Tulis\t";   cout << "| 6.  Spidol\t\t" << endl;   
 cout << "| 2.  Pensil\t\t";   cout << "| 7.  Rautan\t\t" << endl;   
 cout << "| 3.  Bolpoint\t\t";   cout << "| 8.  Gunting\t\t" << endl;   
 cout << "| 4.  Penggaris\t\t";   cout << "| 9.  Buku Gambar\t" << endl;   
 cout << "| 5.  Penghapus\t\t";   cout << "| 10. Sampul Buku\t" << endl << endl;  

 cout << "| 11. Lem\t\t";    cout << "| 16. DVD Blank" << endl;
 cout << "| 12. Isolasi\t\t";  cout << "| 17. Map" << endl;
 cout << "| 13. Kertas Karton\t";  cout << "| 18. Penjepit Kertas" << endl;
 cout << "| 14. Kertas Bufalo\t";  cout << "| 19. Kertas Mika" << endl;
 cout << "| 15. CD Blank\t\t";   cout << "| 20. Permen" << endl;
 cout << "--------------------------------------------------------------"<< endl << endl << endl;
 
 }

/**
PROGRAM KASIR SEDERHANA
alfiansyahmaulana.blogspot.co.id
*/
 
 uwes:
 
 system("cls");
 
 setcolor(187);  gotoxy (13, 30);  cout << "                                                        ";
 setcolor(159);  gotoxy (13, 31);  cout << "  STRUK BELANJA || WWW.ALFIANSYAHMAULANA.BLOGSPOT.COM   ";
 setcolor(187);  gotoxy (13, 32);  cout << "                                                        ";
 
 setcolor(170);  gotoxy (1, 35);  cout << "----------------------------------------------------------------------------"; 
     gotoxy (1, 36);  cout << "|";
 setcolor(11);  gotoxy (7, 36);  cout << "NAMA BARANG";  setcolor(170); gotoxy (23, 36); cout << "|";
 setcolor(11);  gotoxy (27, 36);  cout << "HARGA SATUAN"; setcolor(170); gotoxy (42, 36); cout << "|"; 
 setcolor(11);  gotoxy (47, 36);  cout << "JUMLAH";   setcolor(170); gotoxy (58, 36); cout << "|";
 setcolor(11);  gotoxy (63, 36);  cout << "SUBTOTAL";  setcolor(170); gotoxy (76, 36); cout << "|";
 setcolor(170);  gotoxy (1, 37);  cout << "----------------------------------------------------------------------------"; 
   
 for (j=1; j <= i; j++)
 {
 setcolor(170);  gotoxy (1, 37+j);  cout << "|";
 setcolor(14);  gotoxy (4, 37+j);  cout << tampilbarang[j];  setcolor(170); gotoxy (23, 37+j); cout << "|";
 setcolor(14);  gotoxy (26, 37+j);  cout << harga[j];    setcolor(170); gotoxy (42, 37+j); cout << "|";
 setcolor(14);  gotoxy (46, 37+j);  cout << jumlahbarang[j];  setcolor(170); gotoxy (58, 37+j); cout << "|";
 setcolor(14);  gotoxy (61, 37+j);  cout << total[j];    setcolor(170); gotoxy (76, 37+j); cout << "|";
 } 

 setcolor(170);  gotoxy (1, 37+j);  cout << "----------------------------------------------------------------------------";
     gotoxy (1, 38+j);  cout << "|";
 setcolor(15);  gotoxy (40, 38+j);  cout << "TOTAL HARGA = ";
     gotoxy (61, 38+j);  cout << totalharga;
 setcolor(170);  gotoxy (76, 38+j);  cout << "|";
 setcolor(15);  gotoxy (57, 38+j);  cout << "Rp.";
 setcolor(170);  gotoxy (1, 39+j);  cout << "|";
 
 bayarsalah:
 setcolor(15); gotoxy (27, 39+j);  cout << "MASUKKAN UANG PEMBAYARAN = ";
     gotoxy (57, 39+j);  cout << "Rp. ";
 
  while (getline(cin, line))
     {
         stringstream ss(line);
         if (ss >> bayar)
         {
             if (ss.eof())
             {   
                 break;
             }
         }
    setcolor(256);  gotoxy (27, 39+j);  cout << "                                                                                                                                                                                                               ";
    setcolor(252); gotoxy(50, 40+j);  cout << " MASUKKAN SALAH !! ";
 setcolor(15); gotoxy (27, 39+j); cout << "MASUKKAN UANG PEMBAYARAN = ";
     gotoxy (57, 39+j);  cout << "Rp. ";
  }
 
 setcolor(256); gotoxy(50, 40+j);  cout << "                                      "; 
 
 while (bayar%100!=0)
 {
 setcolor(256); gotoxy (27, 39+j);  cout << "                                                                                                                                                                                                               ";
    setcolor(252);  gotoxy(50, 40+j);  cout << " UANG PEMBAYARAN SALAH !! ";
 goto bayarsalah; 
 } 
 
 setcolor(170); gotoxy (76, 39+j);  cout << "|";
     gotoxy (1, 40+j);  cout << "|";
     gotoxy (76, 40+j);  cout << "|";
 
 kembalian=bayar-totalharga;
 
 setcolor(14);
 if (kembalian!=0 && kembalian>0)
 {
 setcolor(170);  gotoxy (1, 41+j);  cout << "|"; 
 setcolor(15);  gotoxy (42, 41+j);  cout << "KEMBALIAN = ";
     gotoxy (57, 41+j);  cout << "Rp. "; 
     gotoxy (61, 41+j);  cout << kembalian;
 setcolor(170);  gotoxy (76, 41+j);  cout << "|";
     gotoxy (1, 42+j);  cout << "----------------------------------------------------------------------------";
 setcolor(30);  gotoxy (1, 44+j);  cout << "TERIMA KASIH ATAS PEMBELIAN DI TOKO KAMI..";
 }
 
 if (kembalian<0)
 {
 setcolor(170); gotoxy (1, 41+j);  cout << "|"; 
 setcolor(206); gotoxy (29, 41+j);  cout << "UANG PEMBAYARAN KURANG = ";
     gotoxy (57, 41+j);  cout << "Rp. "; 
     gotoxy (61, 41+j);  cout << kembalian;
 setcolor(170); gotoxy (76, 41+j);  cout << "|";
     gotoxy (1, 42+j);  cout << "----------------------------------------------------------------------------";
 setcolor(30); gotoxy (1, 44+j);  cout << "TERIMA KASIH ATAS PEMBELIAN DI TOKO KAMI.."; 
 setcolor(206); gotoxy (1, 45+j); cout << "DAN JANGAN LUPA UNTUK MELUNASI KEKURANGAN !!";
 }
 
 if (kembalian==0)
 {
 setcolor(170); gotoxy (1, 41+j);  cout << "----------------------------------------------------------------------------";
 setcolor(30); gotoxy (1, 43+j);  cout << "TERIMA KASIH ATAS PEMBELIAN DI TOKO KAMI..";
 }
 
 cout << endl << endl << endl << endl;
 
/**
PROGRAM KASIR SEDERHANA
alfiansyahmaulana.blogspot.co.id
*/
 if (kembalian != 0 && kembalian > 0 )
 {
 setcolor(74); gotoxy (0, 46+j); cout << "SARAN KEMBALIAN :   " << endl;
 
 setcolor(10);
 for (i=1; kembalian>=100000; i++)
 {
  kembalian=kembalian-100000;
  
  if(kembalian<100000)
  {
  cout << i; cout << " Lembar Rp. 100000" << endl;  
  }
 }
 
 for (i=1; kembalian>=50000; i++)
 {
  kembalian=kembalian-50000;
  
  if(kembalian<50000)
  {
  cout << i; cout << " Lembar Rp. 50000" << endl;  
  }
 }
 
 for (i=1; kembalian>=20000; i++)
 {
  kembalian=kembalian-20000;
  
  if(kembalian<20000)
  {
  cout << i; cout << " Lembar Rp. 20000" << endl;  
  }
 }

 for (i=1; kembalian>=10000; i++)
 {
  kembalian=kembalian-10000;
  
  if(kembalian<10000)
  {
  cout << i; cout << " Lembar Rp. 10000" << endl;  
  }
 }

 for (i=1; kembalian>=5000; i++)
 {
  kembalian=kembalian-5000;
 
  if(kembalian<5000)
  {
  cout << i; cout << " Lembar Rp. 5000" << endl;  
  }
 }
 
 for (i=1; kembalian>=2000; i++)
 {
  kembalian=kembalian-2000;

  if(kembalian<2000)
  {
  cout << i; cout << " Lembar Rp. 2000" << endl;  
  }
 }

 for (i=1; kembalian>=1000; i++)
 {
  kembalian=kembalian-1000;

  if(kembalian<1000)
  {
  cout << i; cout << " Lembar Rp. 1000" << endl;  
  }
 }

 for (i=1; kembalian>=500; i++)
 {
  kembalian=kembalian-500;

  if(kembalian<500)
  {
  cout << i; cout << " Lembar Rp. 500" << endl;  
  }
 }


 for (i=1; kembalian>=200; i++)
 {
  kembalian=kembalian-200;
 
  if(kembalian<200)
  {
  cout << i; cout << " Lembar Rp. 200" << endl;  
  }
 }
 
 for (i=1; kembalian>=100; i++)
 {
  kembalian=kembalian-100;
 
  if(kembalian<100)
  {
  cout << i; cout << " Lembar Rp. 100" << endl;  
  }
 }
 }

 cout <<endl <<endl ;
 
 string ulangprogram;
 setcolor (14); gotoxy(1, 56+j); cout << "Apakah anda ingin menghitung pembelanjaan lagi ? (y/n) = ";
 getline(cin, ulangprogram);
 string yes;
 string Yes;
 string no;
 string No;
 
 yes='y';
 Yes='Y';
 no='n';
 No='N';
 
   while (ulangprogram!=yes && ulangprogram!=Yes && ulangprogram!=no && ulangprogram!=No) 
 { 
  setcolor (256); gotoxy(1, 56+j); cout << "                                                                                                                                                                                                               ";
  setcolor (252); gotoxy(1, 57+j); cout << "KETIKKAN >> Y << UNTUK MENGULANG PROGRAM ATAU >> N << UNTUK KELUAR PROGRAM !!"<< endl << endl;
  setcolor (14);  gotoxy(1, 56+j); cout << "Apakah anda ingin menghitung pembelanjaan lagi ? (y/n) = ";
  getline(cin, ulangprogram);
 }
 if (ulangprogram==yes || ulangprogram==Yes) 
 {
  goto awalprogram;
 }
   if (ulangprogram==no || ulangprogram==No) 
 {
  goto akhirprogram;
 }
 
 akhirprogram:
 setcolor (256); gotoxy(1, 56+j); cout << "                                                                                          "; 
 setcolor (256); gotoxy(1, 57+j); cout << "                                                                                          "; 

return 0;

}

/**
PROGRAM KASIR SEDERHANA
alfiansyahmaulana.blogspot.co.id
*/

ARTIKEL TERKAIT:


BACA JUGA TULISAN MENARIK LAINNYA :

2 comments: