Jumat, 22 April 2011

Tugas C++ Tipe C

# include <iostream.h>
# include <stdio.h>
# include <conio.h>
main ()
{
  char np[30],kode[5],*nmbrg;
  int lama,hrg,total,adm=50000,diskon,tobay;

  cout<<"    .:LENEN KOMPUTER:.    "<<endl;
  cout<<" Jl. Wijaya Kusuma Jalarta"<<endl;
  cout<<"**************************"<<endl;
  cout<<"Nama Penyewa\t:";gets(np);
  cout<<"Kode\t        :";cin>>kode;
  cout<<"Lama Sewa\t:";cin>>lama;

  if (strcmpi(kode,"L-01")==0)
                {nmbrg="Laptop";
                hrg=1000000;
   }
  else if (strcmpi(kode,"L-02")==0)
       {nmbrg="LCD";
                  hrg=850000;
       }
        else if (strcmpi(kode,"K-01")==0)
                                {nmbrg="Komputer";
             hrg=650000;
            }

   if (lama >5)
                diskon=0.01*(lama*hrg);
   else
   diskon=0;



  cout<<endl;
  cout<<"   .:LENEN KOMPUTER:.   "<<endl;
  cout<<"Jl. Wijaya Kusuma Jakarta"<<endl;
  cout<<"========================="<<endl;
  cout<<"Nama Penyawa     :"<<np<<endl;
  cout<<"Kode             :"<<kode<<endl;
  cout<<"Nama Barang      :"<<nmbrg<<endl;
  cout<<"Harga Sewa/hari  :"<<hrg<<endl;
  cout<<"Lama Sewa        :"<<lama;cout<<" hari "<<endl;
  total=(hrg*lama)-diskon;
  tobay=total+adm;
  cout<<"Total Harga Sewa :"<<total<<endl;
  cout<<"Total Biaya      :"<<tobay<<endl;
  cout<<"========================="<<endl;
  getch();
 
}