Tuesday, January 22, 2019

√ Fungsi If Pada Pemrograman C++ (Part2)

#include
#include
#include
main( )
{
char *mobil;
int kode;
long harga,l_sewa,u_bayar,u_kembali,tot_sewa;

clrscr();
cout<<" "<cout<<"KODE MOBIL:";cin>>kode;
cout<<"LAMA SEWA :";cin>>l_sewa;
if (kode==1)
  {
  mobil="MAZDA";
  harga=200000;
  }
else if (kode==2)
  {
  mobil="TOYOTA";
  harga=190000;
  }
else if (kode==3)
  {
  mobil="ISUZU";
  harga=180000;
  }
else
  {
  mobil="KODE SALAH";
  harga=0;
  }

clrscr();
cout<<"        THE ANGKOT     "<cout<<" "<cout<<"KODE MOBIL       : "<cout<<"NAMA MOBIL       : "<cout<<"HARGA PERHARI    : "<cout<<"LAMA SEWA        : "<tot_sewa=harga*l_sewa;
cout<<"TOTAL SEWA       : "<cout<<"UANG BAYAR       : ";cin>>u_bayar;
u_kembali=u_bayar-tot_sewa;
cout<<"UANG KEMBALI     : "<cout<<"+++++++++++++++++++++++++++++"<cout<<"NAMA     : Ilham Saputra \n";
cout<<"KELAS    : 12.1G.14.A \n";
cout<<"NIM      : 12124166 \n";

getch();
}

Sumber http://www.hendrisetiawan.com