Friday, 9 November 2012








Yosh, saya datang kembalii.. :D
kali ini saya akan share tentang membuat program penjualan sederhana dengan C++

apa anda penasaran?? marii liahat coding di bawah ini :

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

int main()
{
awal:
clrscr ();
int beli,pilih;
cout<<"===================================================\n";
cout<<"==                 PROGRAM PENJUALAN SEDERHANA                  ==\n";
cout<<"===================================================\n"<<endl;

cout<<"===================================================\n";
cout<<"1. T-Shirt PHP          ||      Harga Rp. 75.000  |\n";
cout<<"2. Sepatu RIPCURL       ||      Harga Rp. 125.000 |\n";
cout<<"3. Jacket Trojan        ||      Harga Rp. 95.000  |\n";
cout<<"4. TAS PALLAZO          ||      Harga Rp. 140.000 |\n" ;
cout<<"===================================================\n";
cout<<"---------------------------------------------------\n";
cout<<"     Setelah memilih Barang Lalu Tekan 'ENTER'     \n";
cout<<"---------------------------------------------------\n"<<endl;

cout<<"Pilih Barang "; cin>>pilih;
cout<<"--------------------\n";
cout<<"Mau Beli Berapa ?? ";cin>>beli;
cout<<endl;

if(pilih==1 ){
    int hrg=75000;
   int xhrg;
   xhrg=hrg*beli;
            if(xhrg>=50000 && xhrg<=80000){
                        int diskon,tot;
                        diskon=(xhrg*5)/100;
                        tot=xhrg-diskon;
                     cout<<"===================================================\n";
 cout<<"==                Barang Yang Anda pilih Adalah T-Shirt PHP          ==\n";                        cout<<"===================================================\n"<<endl;
                        cout<<"---------------------------------------------------"<<endl;
                             cout<<"Harga Awal          = "<<"Rp. "<<hrg<<"\n";
                             cout<<"Beli "<<beli<<"              = "<<"Rp. "<<xhrg<<"\n";
                             cout<<"Diskon 5%           = "<<"Rp. "<<diskon<<"\n";
                             cout<<"Total Harga         = "<<"Rp. "<<tot<<"\n";
                        cout<<"---------------------------------------------------"<<endl;
            }else if(xhrg>=100000 && xhrg<=150000){
                        int diskon,tot;
                        diskon=(xhrg*7.5)/100;
                        tot=xhrg-diskon;
                        cout<<"===================================================\n";
                        cout<<"==   Barang Yang Anda pilih Adalah T-Shirt PHP   ==\n";
                        cout<<"===================================================\n"<<endl;
                        cout<<"---------------------------------------------------"<<endl;
                             cout<<"Harga Awal          = "<<"Rp. "<<hrg<<"\n";
                             cout<<"Beli "<<beli<<"              = "<<"Rp. "<<xhrg<<"\n";
                             cout<<"Diskon 7.5%         = "<<"Rp. "<<diskon<<"\n";
                             cout<<"Total Harga         = "<<"Rp. "<<tot<<"\n";
                         cout<<"---------------------------------------------------"<<endl;
            }else if(xhrg>=160000 && xhrg<=250000){
                        int diskon,tot;
                        diskon=(xhrg*12.5)/100;
                        tot=xhrg-diskon;
                        cout<<"===================================================\n";
                        cout<<"==   Barang Yang Anda pilih Adalah T-Shirt PHP   ==\n";
                        cout<<"===================================================\n"<<endl;
                        cout<<"---------------------------------------------------"<<endl;
                             cout<<"Harga Awal          = "<<"Rp. "<<hrg<<"\n";
                             cout<<"Beli "<<beli<<"              = "<<"Rp. "<<xhrg<<"\n";
                             cout<<"Diskon 12.5%        = "<<"Rp. "<<diskon<<"\n";
                             cout<<"Total Harga         = "<<"Rp. "<<tot<<"\n";
                         cout<<"---------------------------------------------------"<<endl;
            }else if(xhrg>250000){
                        int diskon,tot;
                        diskon=(xhrg*20)/100;
                        tot=xhrg-diskon;
                        cout<<"===================================================\n";
                        cout<<"==   Barang Yang Anda pilih Adalah T-Shirt PHP   ==\n";
                        cout<<"===================================================\n"<<endl;
                        cout<<"---------------------------------------------------"<<endl;
                             cout<<"Harga Awal          = "<<"Rp. "<<hrg<<"\n";
                             cout<<"Beli "<<beli<<"              = "<<"Rp. "<<xhrg<<"\n";
                             cout<<"Diskon 20%          = "<<"Rp. "<<diskon<<"\n";
                             cout<<"Total Harga         = "<<"Rp. "<<tot<<"\n";
                         cout<<"---------------------------------------------------"<<endl;
         }
}else if(pilih==2 ){
    int hrg=125000;
   int xhrg;
   xhrg=hrg*beli;
           if(xhrg>=100000 && xhrg<=150000){
                int diskon,tot;
                diskon=(xhrg*7.5)/100;
                tot=xhrg-diskon;
                        cout<<"===================================================\n";
                        cout<<"== Barang Yang Anda pilih Adalah SEPATU RIPCURL  ==\n";
                        cout<<"===================================================\n"<<endl;
                        cout<<"---------------------------------------------------"<<endl;
                              cout<<"Harga Awal          = "<<"Rp. "<<hrg<<"\n";
                              cout<<"Beli "<<beli<<"              = "<<"Rp. "<<xhrg<<"\n";
                              cout<<"Diskon 7.5%         = "<<"Rp. "<<diskon<<"\n";
                              cout<<"Total Harga         = "<<"Rp. "<<tot<<"\n";
                        cout<<"---------------------------------------------------"<<endl;
            }else if(xhrg>=160000 && xhrg<=250000){
                int diskon,tot;
                diskon=(xhrg*12.5)/100;
                tot=xhrg-diskon;
                        cout<<"===================================================\n";
                        cout<<"== Barang Yang Anda pilih Adalah SEPATU RIPCURL  ==\n";
                        cout<<"===================================================\n"<<endl;
                        cout<<"---------------------------------------------------"<<endl;
                              cout<<"Harga Awal          = "<<"Rp. "<<hrg<<"\n";
                              cout<<"Beli "<<beli<<"              = "<<"Rp. "<<xhrg<<"\n";
                              cout<<"Diskon 12.5%        = "<<"Rp. "<<diskon<<"\n";
                              cout<<"Total Harga         = "<<"Rp. "<<tot<<"\n";
                        cout<<"---------------------------------------------------"<<endl;
            }else if(xhrg>250000){
                int diskon,tot;
                diskon=(xhrg*20)/100;
                tot=xhrg-diskon;
                        cout<<"===================================================\n";
                        cout<<"== Barang Yang Anda pilih Adalah SEPATU RIPCURL  ==\n";
                        cout<<"===================================================\n"<<endl;
                        cout<<"---------------------------------------------------"<<endl;
                              cout<<"Harga Awal          = "<<"Rp. "<<hrg<<"\n";
                              cout<<"Beli "<<beli<<"              = "<<"Rp. "<<xhrg<<"\n";
                              cout<<"Diskon 20%          = "<<"Rp. "<<diskon<<"\n";
                              cout<<"Total Harga         = "<<"Rp. "<<tot<<"\n";
                        cout<<"---------------------------------------------------"<<endl;
            }
}else if(pilih==3 ){
    int hrg=95000;
   int xhrg;
   xhrg=hrg*beli;
            if(xhrg>=80000 && xhrg<=125000){
                int diskon,tot;
                diskon=(xhrg*7.5)/100;
                tot=xhrg-diskon;
                        cout<<"===================================================\n";
                        cout<<"==  Barang Yang Anda pilih Adalah JACKET TROJAN  ==\n";
                        cout<<"===================================================\n"<<endl;
                        cout<<"---------------------------------------------------"<<endl;
                          cout<<"Harga Awal          = "<<"Rp. "<<hrg<<"\n";
                     cout<<"Beli "<<beli<<"              = "<<"Rp. "<<xhrg<<"\n";
                          cout<<"Diskon 7.5%         = "<<"Rp. "<<diskon<<"\n";
                     cout<<"Total Harga         = "<<"Rp. "<<tot<<"\n";
                        cout<<"---------------------------------------------------"<<endl;
            }else if(xhrg>=125000 && xhrg<=250000){
                int diskon,tot;
                diskon=(xhrg*12.5)/100;
                tot=xhrg-diskon;
                        cout<<"===================================================\n";
                        cout<<"==  Barang Yang Anda pilih Adalah JACKET TROJAN  ==\n";
                        cout<<"===================================================\n"<<endl;
                        cout<<"---------------------------------------------------"<<endl;
                          cout<<"Harga Awal          = "<<"Rp. "<<hrg<<"\n";
                     cout<<"Beli "<<beli<<"              = "<<"Rp. "<<xhrg<<"\n";
                          cout<<"Diskon 12.5%        = "<<"Rp. "<<diskon<<"\n";
                     cout<<"Total Harga         = "<<"Rp. "<<tot<<"\n";
                        cout<<"---------------------------------------------------"<<endl;
           }else if(xhrg>250000){
                int diskon,tot;
                diskon=(xhrg*20)/100;
                tot=xhrg-diskon;
                        cout<<"===================================================\n";
                        cout<<"==  Barang Yang Anda pilih Adalah JACKET TROJAN  ==\n";
                        cout<<"===================================================\n"<<endl;
                        cout<<"---------------------------------------------------"<<endl;
                          cout<<"Harga Awal          = "<<"Rp. "<<hrg<<"\n";
                     cout<<"Beli "<<beli<<"              = "<<"Rp. "<<xhrg<<"\n";
                          cout<<"Diskon 20%          = "<<"Rp. "<<diskon<<"\n";
                     cout<<"Total Harga         = "<<"Rp. "<<tot<<"\n";
                        cout<<"---------------------------------------------------"<<endl;
           }
}else if(pilih==4 ){
    int hrg=140000;
   int xhrg;
   xhrg=hrg*beli;
            if(xhrg>=125000 && xhrg<=250000){
                int diskon,tot;
                diskon=(xhrg*7.5)/100;
                tot=xhrg-diskon;
                        cout<<"===================================================\n";
                        cout<<"==   Barang Yang Anda pilih Adalah TAS PALLAZO   ==\n";
                        cout<<"===================================================\n"<<endl;
                        cout<<"---------------------------------------------------"<<endl;
                              cout<<"Harga Awal          = "<<"Rp. "<<hrg<<"\n";
                        cout<<"Beli "<<beli<<"              = "<<"Rp. "<<xhrg<<"\n";
                        cout<<"Diskon 7.5%         = "<<"Rp. "<<diskon<<"\n";
                              cout<<"Total Harga         = "<<"Rp. "<<tot<<"\n";
                                cout<<"---------------------------------------------------"<<endl;
            }else if(xhrg>250000){
                int diskon,tot;
                diskon=(xhrg*12.5)/100;
                tot=xhrg-diskon;
                        cout<<"===================================================\n";
                        cout<<"==   Barang Yang Anda pilih Adalah TAS PALLAZO   ==\n";
                        cout<<"===================================================\n"<<endl;
                        cout<<"---------------------------------------------------"<<endl;
                              cout<<"Harga Awal          = "<<"Rp. "<<hrg<<"\n";
                        cout<<"Beli "<<beli<<"              = "<<"Rp. "<<xhrg<<"\n";
                        cout<<"Diskon 12.5%        = "<<"Rp. "<<diskon<<"\n";
                              cout<<"Total Harga         = "<<"Rp. "<<tot<<"\n";
                                cout<<"---------------------------------------------------"<<endl;
           }
}else{
cout<<"maaf pilihan yang anda masukkan tidak ada\n";
}
   balik:
    cout<<"ulangi lagi : [y/n] ? "  ;
    char m ;
    cin>>m;
        if (m == 'y'){
            goto awal ;
            }
        else if (m == 'n')
            {
            cout<<"Terimakasih Telah Menggunakan Program Ini\n";
            goto akhir;
            }
        else
            {
            cout<<"Maap Keyword Salah "<<endl;
            goto balik;
            }

getch();
akhir:
}
nah mudah kan!! Selamat Mencoba!1

3 comments:

  1. diskountnya cuma sampe 20% pada pembelian 20 pcs yah gan ?

    ini saya juga lg dapat tugas yg mirip dengan ini. cuman bedanya dalah pada barang yg di jual itu adalah buah-buahan dan masing2 buah memiliki kualitas berbeda a, b, dan c serta tiap2 kualitas harga beda pula. bagai mana untuk yang itu ?

    ReplyDelete
    Replies
    1. tinggal diginikan aja gan .
      misal kita inputkan buah apa yg dibeli

      #include
      #include
      #include

      void main(){
      char kualitas;
      int pil;
      int harga=0;
      cout<<"1. APEL"<>pil;

      switch(pil){
      case 1:
      cin>>kualitas;
      if(kualitas=='a'){
      harga=15000;
      }
      else if(kualitas=='b'){
      harga=12000;
      }
      if(kualitas=='c'){
      harga=10000;
      }
      cout<<"Buah Apel"<<endl;
      cout<<"Kualitas = "<<kualitas<<endl;
      cout<<"harga = "<<harga;

      break;
      case 2:
      cin>>kualitas;
      if(kualitas=='a'){
      harga=13000;
      }
      break;
      }

      getch() ;
      }

      Delete
  2. thanks gan sukses selalu ya

    ReplyDelete