PROGRAM C++ PENJUALAN

Contoh program "penjualan barang" sederhana


#include <iostream>
#include <conio.h>

main()
{
    int kode, harga, jumlah, total;
    char nama [20];
    cout << "    * PROGRAM PENJUALAN BARANG *\n";
    cout << "------------------------------------\n";
    cout << "Masukan Kode Barang    : ";
    cin >> kode;
    cout << "Masukan Nama Barang    : ";
    cin >> nama;
    cout << "Masukan Harga Barang    : ";
    cin >> harga;
    cout << "Jumlah Beli        : ";
    cin >> jumlah;
    cout << "------------------------------------" << endl;
  
    total = harga * jumlah;
  
    cout << "Proses Total - harga x jumlah beli" << endl;
  
    //Output
  
    cout << "    * STRUK PEMBAYARAN *" << endl;
    cout << "////////////////////////////////////" << endl;
    cout << "Nama Barang        : " << nama << endl;
    cout << "Harga Barang        : " << harga << endl;
    cout << "Jumlah Beli        : " << jumlah << endl;
    cout << "Total            : " << total << endl;
    cout << "/////////////////////////////////////" << endl;
    cout << "     ~~ Trima Kasih ~~";
    getch();
}

Dan Hasil nya akan seperti ini .. 😊




=================================================================


PENJUALAN KUE

#include <iostream.h>
int main ()
{
     char namapembeli[20],kodekue[20],namakue[20];


        cout << "Nama   : zakiyaturrahmah " <<endl;
        cout << "Npm  : 2005160404 " <<endl;

        cout <<"                         *******************************" <<endl; 
        cout <<"                            KUE MOMY" <<endl;
        cout <<"                         *******************************" <<endl;

        cout << "Nama Pembeli  = " ; cin >> namapembeli;
        cout << "Kode Kue  = " ; cin >> kodekue;
        cout << "Nama Kue  = " ; cin >> namakue;
        int hargakue;
        cout << "Harga Kue  = " ; cin >> hargakue;
        int jumlahkue;
        cout << "Jumlah Kue  = " ; cin >> jumlahkue;
        int totalharga = jumlahkue*hargakue;
        cout << "Total Harga  = " << totalharga <<endl;
        cout << "*******************************" <<endl;

        int diskon = totalharga-diskon;
        if (jumlahkue>=20)
        {
         diskon = totalharga*20/100;
        }
         else
        {
         diskon = 0;
        }
        cout << "Diskon = Rp. " << diskon <<endl;
        cout <<"*******************************" <<endl;

        int totalbayar = totalharga-diskon;
        cout << "Total Bayar = Rp. "<< totalbayar <<endl;
        }


==================================================================

PENJULAN SEPATU


# include <stdio.h>
# include <conio.h>
# include <iostream.h>
int main()
{
char pilihanMerk,*merkSepatu,beliLgi;
int ttlBayar,Kembalian,jmlPembelian,hargaProduk,totalHarga;

atas:
 cout<<"===================================================="<<endl;
 cout<<"\tPenjualan Sepatu"<<endl;
 cout<<"===================================================="<<endl;
 cout<<endl;
 cout<<"----------------------------------------------------"<<endl;
 cout<<"Pilihan Merek Sepatu"<<endl;
 cout<<"----------------------------------------------------"<<endl; 
 cout<<"1. Adidas"<<endl;
 cout<<"2. Nike"<<endl;
 cout<<"3. Homyped"<<endl;
 cout<<"4. Carvil"<<endl;
 cout<<"5. Hush Puppies"<<endl;
 cout<<"----------------------------------------------------"<<endl;
 cout<<"Merek Sepatu [1-5]  : ";cin>>pilihanMerk;
 cout<<"Jumlah Pembelian  : ";cin>>jmlPembelian;
 cout<<"----------------------------------------------------"<<endl;

  if(pilihanMerk=='1'){merkSepatu="Adidas";
  hargaProduk=53000;}
  else if(pilihanMerk=='2'){merkSepatu="Nike";
  hargaProduk=80000;}
  else if(pilihanMerk=='3'){merkSepatu="Homyped";
  hargaProduk=750000;}
  else if(pilihanMerk=='4'){merkSepatu="Carvil";
  hargaProduk=110000;}
  else if(pilihanMerk=='5'){merkSepatu="Hush Puppies";
  hargaProduk=680000;}
  else
  {
   cout<<"Maaf, merek tidak tersedia"<<endl;
   cout<<"Pilih kembali";getch();
   cout<<endl;
   goto atas;
  }
 totalHarga=hargaProduk*jmlPembelian;
 cout<<"Merek Sepatu   : "<<merkSepatu<<endl;
 cout<<"Harga Satuan   : Rp. "<<hargaProduk<<endl;
 cout<<"Jumlah Pembelian  : "<<jmlPembelian<<endl;
 cout<<"Total Harga   : Rp. "<<totalHarga<<endl;
 cout<<"----------------------------------------------------"<<endl;
 cout<<"Total Bayar   : Rp. ";
 cin>>ttlBayar;
 Kembalian=ttlBayar-totalHarga;
 cout<<"Kembalian   : Rp. "<<Kembalian<<endl<<endl;
 cout<<"===================================================="<<endl;
 cout<<"Beli kembali produk? [Y/T] : ";cin>>beliLgi;
 cout<<endl;
  if(beliLgi=='Y'||beliLgi=='y')
  {goto atas;}
  else{
   cout<<"Terima Kasih Atas Pembelian Produk Kami";
   cout<<endl;
  }
getch();
}





==================================================================
PENJUALAN UNIT KOMPUTER

#include<iostream.h>
int main()
{
 char kode;
 char* nama_barang;
 char* harga_barang;
 long int tot_harga, jumlah;

 cout<<" DAFTAR NAMA BARANG BERDASARKAN KODE \n";
 cout<<" ************* \n";
  cout<<" 1: monitor, harga Rp 500000 \n";
  cout<<" 2: cpu harga Rp 1000000\n";
  cout<<" 3: hardisk harga Rp 400000\n";
 cout<<" ************* \n";
 cout<<"\n";

 cout<<"input kode barang : ";
 cin>>kode;
 cout<<"input jumlah barang : ";
 cin>>jumlah;

 if (kode =='1' )
 {
  nama_barang ="monitor";
  harga_barang ="500000";
  tot_harga=jumlah*500000;
 }

 if (kode =='2' )
 {
  nama_barang ="cpu";
  harga_barang ="1000000";
  tot_harga=jumlah*1000000;
 }

 if (kode =='3' )
 {
  nama_barang ="hardisk";
  harga_barang ="400000";
  tot_harga=jumlah*400000;
 }

 cout<<"nama barang "  <<nama_barang<<endl;
 cout<<"harga barang "  <<harga_barang<<endl;
 cout<<"Total harga barang Rp " <<tot_harga<<endl;

 return 0;
}


=============================================================================================

PENJULAN PULSA

#include<stdio.h>
#include<conio.h>
#include<iostream.h>

main ()
{
char kode;
int kopul;
char op[10];
int nominal,harga;
clrscr();
cout<<"              PULSA"<<endl;
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"KODE OPERATOR [I/S]   :"; cin>>kode;
cout<<"KODE PULSA    [5/10]  :"; cin>>kopul;
if(kode=='I')
 {
   strcpy(op,"Indosat");
   if(kopul==5)
    {
      nominal=5000;
      harga=5200;
      }
   else if(kopul==10)
    {
      nominal=10000;
      harga=100200;
      }
   else
    {
      nominal=0;
      harga=0;
      }
 if(kode=='S')
 {
   strcpy(op,"Telkomsel");
   if(kopul==5)
    {
      nominal=5000;
      harga=5300;
      }
   else if(kopul==10)
    {
      nominal=10000;
      harga=100300;
      }
   else
    {
      nominal=0;
      harga=0;
      }    }}
else
{
strcpy(op,"kode salah");
nominal=0;
harga=0;
}

cout<<"NAMA OPERATOR         :"<<op<<endl;
cout<<"NOMINAL PULSA         :"<<nominal<<endl;
cout<<"HARGA                 :"<<harga<<endl;
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;


getch();
}



Komentar

Postingan Populer