.articlehidden {display:none} .articleshown {display:inline}

Saturday, 21 September 2013

Contoh listing (coding) Borland C++

# include <stdio.h>
# include <conio.h>
# include <iostream.h>
main()
{
 char nama[15],kode,*barang;
 long jumlah,bayar;
 int harga,sub,total,kembali,diskon;
 clrscr();
 cout<<"============================================================"<<endl;
 cout<<"                      Yussaysi Komputer                       "<<endl;
 cout<<"============================================================"<<endl;
 cout<<"------------------------------------------------------------"<<endl;
 cout<<">>>>> Input Nama Customer :";cin>>nama;
 cout<<""<<endl;
 cout<<"------------------------------------------------------------"<<endl;
 cout<<"Kode barang :  Nama barang   :               Harga barang :"<<endl;
 cout<<""<<endl;
 cout<<"   1).         Hardisk PC (Maxtor) 320 GB.    Rp. 350.000"<<endl;
 cout<<"   2).         Hardisk Laptop (Zyrex) 320 GB. Rp. 450.000"<<endl;
 cout<<"   3).         VGA Card PC 400 Pixel.         Rp. 375.000"<<endl;
 cout<<"   4).         Mouse Wireless Comic.          Rp. 150.000"<<endl;
 cout<<"   5).         Keyboard Wireless Comic.       Rp. 180.000"<<endl;
 cout<<"-----------------------------------------------------------"<<endl;
 cout<<">>>> Masukan Kode Pilihan [1/2/3/4/5]:";cin>>kode;
 cout<<"==========================================================="<<endl;
 if (kode=='1')
  {
   barang="Hardisk PC (Maxtor) 320 GB.";
   harga=350000;
   }
 else if (kode=='2')
   {
    barang="Hardisk Laptop (Zyrex) 320 GB.";
    harga=450000;
    }
 else if (kode=='3')
   {
   barang="VGA Card PC 400 Pixel.";
   harga= 375000;
   }
 else if (kode=='4')
   {
    barang="Mouse Wireless Comic.";
    harga=150000;
    }
 else if (kode=='5')
  {
   barang="Keyboard Wireless Comic.";
    harga=180000;
    }
 else
 clrscr();
 cout<<"Salah Memasukan Kode"<<endl;
 cout<<"<<>> Nama Customer   : "<<nama<<endl;
 cout<<"<<>> Nama Barang     : "<<barang<<endl;
 cout<<"<<>> Harga           : Rp."<<harga<<endl;
 cout<<"==========================================================="<<endl;
 cout<<">>>> Input Jumlah Beli  :";cin>>jumlah;
 cout<<"==========================================================="<<endl;
 sub=harga*jumlah;
 cout<<"<<>>Sub Total        : Rp."<<sub<<endl;
 cout<<"==========================================================="<<endl;
 cout<<"###########################################################"<<endl;
 if (jumlah>=4)
      diskon=sub*10/100;
 else
      diskon=0;
 cout<<"Jumlah Potongan   : Rp."<<diskon<<endl;
total=sub-diskon;
 cout<<"Total Bayar       : Rp."<<total<<endl;
 cout<<"==========================================================="<<endl;
 cout<<"Uang Bayar        : Rp.";cin>>bayar;
 cout<<"----------------------------------------------------------="<<endl;
 kembali=bayar-total;
 cout<<"Uang Kembali      : Rp."<<kembali;
 getch();
 }

No comments: