Sabtu, 20 Oktober 2012

Pemograman ++ Mengunakan Perintah "IF"

Pemograman C++ menggunakan IF, memang sdikit lebih sulit dari yg kemaren, but If there is a will there is a way. ok ga usah lama2, langsung Copypaste kan Scriptnya yg telah ane kerjain ke Borland C++. Here we go !!!




#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main()
{
char nm[10], *nb;
long kp,h,jb,st,p,tb,ub,uk;
cout<<"==============================================================="<<endl;
cout<<"PENJUALAN HARDWARE PC & LAPTOP"<<endl;
cout<<"==============================================================="<<endl;
cout<<"---------------------------------------------------------------"<<endl;
cout<<">>>> Input Nama Costumer  : ";gets(nm);
cout<<"---------------------------------------------------------------"<<endl<<endl;
cout<<"Kode Barang :   Nama Barang :                     Harga Barang"<<endl<<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 Wireles Comic            Rp. 180.000"<<endl;
cout<<"---------------------------------------------------------------"<<endl;
cout<<">>>> Masukan Kode Pilihan [1/2/3/4/5]  :";cin>>kp;
cout<<"==============================================================="<<endl;

if(kp==1)
    {
   nb="Hardisk PC (Maxtor) 320 GB.";
    h=350000;
   }

else if(kp==2)
    {
   nb="Hardisk LAPTOP (Zyrex) 320 GB.";
    h=450000;
   }
else if(kp==3)
    {
   nb="VGA CARD  PC 400 Pixel.";
    h=375000;
   }
else if(kp==4)
    {
   nb="Mouse Wireless Comic";
    h=150000;
   }
else
    {
   nb="Keyboard Wireless Comic";
    h=180000;
   }

cout<<"Nama Costumer : "<<nm<<endl;
cout<<"Nama Barang   : "<<nb<<endl;
cout<<"Harga         : "<<h<<endl;
cout<<"==============================================================="<<endl;
cout<<">>>> Input Jumlah Beli : ";cin>>jb;
cout<<"==============================================================="<<endl;
st=h*jb;
cout<<">><<SubTotal  : Rp."<<st<<endl;
cout<<"==============================================================="<<endl;
cout<<"###############################################################"<<endl;
if(jb>=4)
    {
   p=st*0.1;
   }
else
    {
   p=0;
   }

cout<<"Jumlah Potongan : Rp."<<p<<endl;
tb=st-p;
cout<<"Total Bayar     : Rp."<<tb<<endl;
cout<<"==============================================================="<<endl;
cout<<"Uang Bayar      : Rp.";cin>>ub;
cout<<"---------------------------------------------------------------"<<endl;
uk=ub-tb;
cout<<"Uang Kembali    : Rp."<<uk<<endl;
cout<<"---------------------------------------------------------------"<<endl;


getch();
}


0 komentar:

Posting Komentar