Categories
Pemprogramman C++

Contoh program c++ penjualan dan pembelian

Berikut adalah contoh sederhanan program c++ penjualan dan pembelian, semoga ini bisa bermanfaat dan dijadikan bahana belajar.

#include<iostream>
using namespace std;
main()
{
  char kodeBuku,beli,belanjaKmbl, buku[160];
  float totalByr,jumlahBli,totalBeli,potongan,harga,hargaBuku;
  kembali:
   cout<<"\t   Toko Buku Gramedia";cout<<endl;
   cout<<"\t  Jl.Pengayoman Makassar";cout<<endl;
   cout<<endl;
   cout<<" ====================================================";cout<<endl; cout<<endl;
   cout<<" Masukkan Kode Buku [1-5] : ";cin>>kodeBuku;
   cout<<" Jumlah Pembelian  : ";cin>>jumlahBli;cout<<endl;
   cout<<" ====================================================";cout<<endl; cout<<endl;
  cout<<" Nama Buku        :"<<buku;
   switch(kodeBuku)
    {
     case ('1') :
      {
      cout<<" Arocedural programming"<<buku;
      hargaBuku= 35000;
      harga= 35000*jumlahBli ;
      }
      break;
     case ('2') :
      {
      cout<<" Visual C++"<<buku;

      hargaBuku= 25000;
      harga= 25000*jumlahBli;
      }
      break;
     case ('3') :
      {
      cout<<" Cara cepat sukses"<<buku;
      hargaBuku= 70000;
      harga= 70000*jumlahBli;
      }
      break;
      case ('4') :
      {
      cout<<" Cara budidaya Ikan"<<buku;
      hargaBuku= 65000;
      harga= 65000*jumlahBli;
      }
      break;
     case ('5') :
      {
      cout<<" Applied Programming"<<buku;
      hargaBuku= 85000;
      harga= 85000*jumlahBli;
      }
      break;
    }
  cout<<endl;


  cout<<" Jumlah Buku      : "<<jumlahBli<<endl;
  cout<<" Harga Buku       : Rp."<<hargaBuku<<endl;
      if (jumlahBli >3)
     {
      potongan = 0.3*harga;
     }
      else
      {
       potongan= 0;
      }
     
     
  cout<<" Total Harga Buku  : Rp."<<harga<<endl;
  cout<<" Potongan Harga                : Rp."<<potongan<<endl;


  totalByr= harga-potongan;
  cout<<" ===================================================="<<endl;
  cout<<" Total Bayar                   : Rp."<<totalByr<<endl;
  cout<<" ===================================================="<<endl;
  cout<<endl;
  cout<<" Belanja Lagi? [Y/T] : ";cin>>belanjaKmbl;
  cout<<endl;
  if(belanjaKmbl=='Y' || belanjaKmbl=='y')
  {goto kembali;}
  if(belanjaKmbl=='T' || belanjaKmbl=='t')
  {goto selesai;}
  selesai:
  cout<<endl;
}

Leave a Reply

Your email address will not be published. Required fields are marked *