Program Rentak Motor menggunakan Bahasa C++
1. buka aplikasi Dev C++
2. Pilih file > New > text edit atau CTRL+N
3. Pastekan koding berikut :
#include <iostream >
#include <conio.h>
#include <conio.h>
#include <stdio.h>
#include <windows.h>
using namespace std;
long int merk_motor[30],dp[30],a[30],sisa,bunga,c,z,total,u_k,bln, harga,batas;
int b,i;
void login();
int cetak();
int data();
int awal();
int menu();
int kawasaki();
int satria();
int nmax();
int scorpion();
int mio();
int konfirmasi();
char k_u[20] = "kahar";
char k_p[20] = "123";
char pake[20];
char u[30];
char nama[30][30],alamat[30][30], nik[20][30], kerja[30][30], hp[20][30], motor[30][50];
int data()
{
cout<<"Masukkan Nama Anda : "; fflush(stdin);gets(nama[i]);
cout<<"Masukkan Alamat Anda : "; gets(alamat[i]);
cout<<"Masukkan No. KTP Anda : "; gets(nik[i]);
cout<<"Masukkan Pekerjan Anda : "; gets(kerja[i]);
cout<<"Masukkan No. Handphone : "; gets(hp[i]);
}
main()
{
login();
// awal();
cetak();
}
void gotoxy(int x,int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
void login()
{
do
{
system("cls");
if (b >= 3)
{
cout<<"Pasword anda d blok";
break;
}
else
{
gotoxy(20,2);cout<<"------------------------------------------------"; //menunjukkan kolom ke 20 dan baris ke 2
gotoxy(20,3);cout<<"| LOGIN IKAFI MOTOR |"; //menunjukkan kolom ke 20 dan baris ke 3
gotoxy(20,4);cout<<"------------------------------------------------";
gotoxy(20,6);cout<<"| Password : |"; //menunjukkan kolom ke 20 dan baris ke 6
gotoxy(20,5);cout<<"| Username : |";
gotoxy(20,7);cout<<"------------------------------------------------";
gotoxy(33,5);fflush(stdin);gets(u);
gotoxy(33,6);cin>>pake;
//proses looping
if ((strcmp(k_u,u)!=0) && (strcmp(k_p,pake)!=0))
{
gotoxy(25,8);cout<<"Username & Password Anda Salah";
getch();
}
else if(strcmp(k_u,u)!=0)
{
gotoxy(25,12);cout<<"Username salah "<<endl;
getch();
}
else if(strcmp(k_p,pake)!=0)
{
gotoxy(35,13);cout<<"Password salah";
i++;
getch();
}
else
{
gotoxy(20,10);cout<<"ANDA BERHASIL LOGIN BERARTI ANDA BUKAN PENYUSUP";
getch();
system("cls");
awal();
}
}
}while((strcmp(k_u,u)!=0) || (strcmp(k_p,pake)!=0));
}
int awal()
{
cout<<"=========================================";
cout<<"\n\n PT. IKAFI ";
cout<<"\n\n (Ina Kahar Fitri) ";
cout<<"\n KREDIT MOTOR ";
cout<<"\n=====================================\n";
menu();
}
int menu ()
{
cout<<endl;
cout<<"|====================================|\n";
cout<<"|========= DAFTAR KODE MOTOR ========|\n";
cout<<"|====================================|\n";
cout<<"|No. | Merk.Motor | Harga | \n";
cout<<"|====|==============|================|\n";
cout<<"| 1. | KAWASAKI | Rp. 25.000.000 | "<<endl;
cout<<"| 2. | SATRIA | Rp. 19.000.000 | "<<endl;
cout<<"| 3. | NMAX | Rp. 20.000.000 | "<<endl;
cout<<"| 4. | SCORPION | Rp. 23.000.000 | "<<endl;
cout<<"| 5. | MIO | Rp. 15.000.000 | "<<endl;
cout<<"|====|==============|================| \n";
cout<<"\n Masukkan Kode Motor (1..5): ";
cin>>merk_motor[i];
system("cls");
switch(merk_motor[i])
{
case 1:kawasaki();break;
case 2:satria();break;
case 3:nmax();break;
case 4:scorpion();break;
case 5:mio();break;
default:
cout<<"\n";
cout<<" SALAH KODE KI BOSS .... !!!! \n\n";
cout<<endl;
menu();
}
return(merk_motor[i]);
}
int konfirmasi()
{
char k;
cout<<endl;
cout<<"======================================================" << endl;
cout<<"\n\n"<<endl;
cout<<"---NOTEBOOK---\n";
cout<<"1.Perhitungan Menggunakan Sistem BUNGA TETAP (6%)\n";
cout<<"2.Bagi PNS, Pengajuan Kredit Dapat Dilakukan Dengan Menyertakan:\n";
cout<<" - KTP\n";
cout<<" - Slip Gaji\n";
cout<<" - Slip Pembayaran Listrik & Telp Terbaru\n";
cout<<" - Slip Pembayaran Koran Terakhir (Bila Ada)\n";
cout<<endl;
cout<<"======================================================" <<endl;
cout<<"\n\nAnda Ingin Kembali Menghitung? [y/t] : ";
cin>>k;
if ((k=='y') || (k=='Y'))
{
system ("cls");
batas++;
menu();
}
else
{
cetak();
}
}
int kawasaki()
{
merk_motor[i]==1;
// harga=25000000;
strcpy(motor[i],"KAWASAKI");
system("cls");
cout<<endl;
cout<<endl;
cout<<"|======================================|"<<endl;
cout<<"| MOTOR KAWASAKI : Rp. 25.000.000 |"<<endl;
cout<<"|======================================|\n"<<endl;
data();
cout<< "-----------------------------------------------------"<<endl;
do{
cout<<"Berapa Uang Muka Yang Anda Inginkan : Rp. ";cin>>dp[i];
u_k = dp[i] - 25000000;
if (dp[i] > 25000000)
{
cout <<"\t---UANG MUKA ANDA MELAMPAUI HARGA MOTOR--- !!!\n"<<endl;
cout <<"\t---BAWA PULANG SAJA ITU MOTOR--- !!! \n\n";
}
else if (dp[i] < 25000000 )
{
sisa=25000000-dp[i];
cout<<"\nSisa pembayaran sejumlah : Rp. "<<sisa<<endl;
}
}while(dp[i] > 25000000);
do{
cout<<"\nBerapa Kali Angsuran Yang Anda Inginkan(Per-bulan): "; cin>>a[i];
bln = a[i] - 36 ;
if ( a[i] > 36 )
{
cout <<"\n\t---ANDA MELAMPAUI BATAS CICILAN PER BULAN--- !!!\n\n"<<endl;
}
else if ( a[i] < 36 )
{
cout<<"-----------------------------------------------------"<<endl;
}
}while(a[i] > 36);
bunga=sisa*6/100;
c=sisa/a[i];
z=c+bunga;
total=z*a[i];
system("cls");
cout<<endl;
cout<<"|==================|"<<endl;
cout<<"| MOTOR KAWASAKI |"<<endl;
cout<<"|==================|\n"<<endl;
cout<<endl;
cout<<"\nSisa Pembayaran Sejumlah : Rp. "<<sisa<<endl;
cout<<"\nDiangsur Sebanyak : "<<a[i]<<" Kali/Bulan"<<endl;
cout<< "-----------------------------------------------------"<<endl;
cout<<"\nAngsuran Yang Harus Dibayar Per-bulan : Rp. "<<z<<endl;
cout<<"\nTotal Angsuran Yang harus Dibayar : Rp. "<<total;
konfirmasi();
i++;
}
int satria()
{
merk_motor[i]==1;
harga=19000000;
strcpy(motor[i],"SATRIA");
system ("cls");
cout<<endl;
cout<<endl;
cout<<"|======================================|"<<endl;
cout<<"| MOTOR SATRIA : Rp. 19.000.000 |"<<endl;
cout<<"|======================================|\n"<<endl;
data();
cout<< "-----------------------------------------------------"<<endl;
do{
cout<<"Berapa Uang Muka Yang Anda Inginkan : Rp. ";cin>>dp[i];
u_k = dp[i] - 19000000;
if (dp[i] > 19000000)
{
cout <<"\t---UANG MUKA ANDA MELAMPAUI HARGA MOTOR--- !!!\n\n"<<endl;
cout <<"\t---BAWA PULANG SAJA ITU MOTOR--- !!! \n\n";
}
else if (dp[i] < 19000000 )
{
sisa=19000000-dp[i];
cout<<"\nSisa pembayaran sejumlah : Rp. "<<sisa<<endl;
}
}while(dp[i] > 19000000);
do{
cout<<"\nBerapa Kali Angsuran Yang Anda Inginkan(Per-bulan): "; cin>>a[i];
bln = a[i] - 36 ;
if ( a[i] > 36 )
{
cout <<"\n\t---ANDA MELAMPAUI BATAS CICILAN PER BULAN--- !!!\n\n"<<endl;
}
else if ( a[i] < 36 )
{
cout<<"-----------------------------------------------------"<<endl;
}
}while(a[i] > 36);
bunga=sisa*6/100;
c=sisa/a[i];
z=c+bunga;
total=z*a[i];
system("cls");
cout<<"|==================|"<<endl;
cout<<"| MOTOR SATRIA |"<<endl;
cout<<"|==================|\n"<<endl;
cout<<endl;
cout<<"\nSisa Pembayaran Sejumlah : Rp. "<<sisa<<endl;
cout<<"\nDiangsur Sebanyak : "<<a[i]<<" Kali/Bulan"<<endl;
cout<< "-----------------------------------------------------"<<endl;
cout<<"\nAngsuran Yang Harus Dibayar Per-Bulan : Rp. "<<z<<endl;
cout<<"\nTotal Angsuran Yang Harus Dibayar : Rp. "<<total;
konfirmasi();
i++;
}
int nmax()
{
merk_motor[i]==1;
harga=20000000;
strcpy(motor[i],"NMAX");
system("cls");
cout<<endl;
cout<<endl;
cout<<"|======================================|"<<endl;
cout<<"| MOTOR NMAX : Rp. 20.000.000 |"<<endl;
cout<<"|======================================|\n"<<endl;
data();
cout<< "-----------------------------------------------------"<<endl;
do{
cout<<"Berapa Uang Muka Yang Anda Inginkan : Rp. ";cin>>dp[i];
u_k = dp[i] - 20000000;
if (dp[i] > 20000000)
{
cout <<"\t---UANG MUKA ANDA MELAMPAUI HARGA MOTOR--- !!!\n\n"<<endl;
cout <<"\t---BAWA PULANG SAJA ITU MOTOR--- !!! \n\n";
}
else if (dp[i] < 20000000 )
{
sisa=20000000-dp[i];
cout<<"\nSisa Pembayaran Sejumlah : Rp. "<<sisa<<endl;
}
}while(dp[i] > 20000000);
do{
cout<<"\nBerapa Kali Angsuran Yang Anda Inginkan(Per-bulan): "; cin>>a[i];
bln = a[i] - 36 ;
if ( a[i] > 36 )
{
cout <<"\n\t---ANDA MELAMPAUI BATAS CICILAN PER BULAN--- !!!\n\n"<<endl;
}
else if ( a[i] < 36 )
{
cout<<"-----------------------------------------------------"<<endl;
}
}while(a[i] > 36);
bunga=sisa*6/100;
c=sisa/a[i];
z=c+bunga;
total=z*a[i];
system("cls");
cout<<"|==================|"<<endl;
cout<<"| MOTOR NMAX |"<<endl;
cout<<"|==================|\n"<<endl;
cout<<endl;
cout<<"\nSisa Pembayaran Sejumlah : Rp. "<<sisa<<endl;
cout<<"\nDiangsur Sebanyak : "<<a[i]<<" Kali/Bulan"<<endl;
cout<< "-----------------------------------------------------"<<endl;
cout<<"\nAngsuran Yang Harus Dibayar Per-Bulan : Rp. "<<z<<endl;
cout<<"\nTotal Angsuran Yang Harus Dibayar : Rp. "<<total;
konfirmasi();
i++;
}
int scorpion()
{
merk_motor[i]==1;
harga=23000000;
strcpy(motor[i],"SCORPION");
system("cls");
cout<<endl;
cout<<endl;
cout<<"|======================================|"<<endl;
cout<<"| MOTOR SCORPION : Rp. 23.000.000 |"<<endl;
cout<<"|======================================|\n"<<endl;
data();
cout<< "-----------------------------------------------------"<<endl;
do{
cout<<"Berapa Uang Muka Yang Anda Inginkan : Rp. ";cin>>dp[i];
u_k = dp[i] - 23000000;
if (dp[i] > 23000000)
{
cout <<"\t---UANG MUKA ANDA MELAMPAUI HARGA MOTOR--- !!!\n\n"<<endl;
cout <<"\t---BAWA PULANG SAJA ITU MOTOR--- !!! \n\n";
}
else if (dp[i] < 23000000 )
{
sisa= 23000000-dp[i];
cout<<"\nSisa Pembayaran Sejumlah : Rp. "<<sisa<<endl;
}
}while(dp[i] > 23000000);
do{
cout<<"\nBerapa Kali Angsuran Yang Anda Inginkan(Per-bulan): "; cin>>a[i];
bln = a[i] - 36 ;
if ( a[i] > 36 )
{
cout <<"\n\t---ANDA MELAMPAUI BATAS CICILAN PER BULAN--- !!!\n\n"<<endl;
}
else if ( a[i] < 36 )
{
cout<<"-----------------------------------------------------"<<endl;
}
}while(a[i] > 36);
bunga=sisa*6/100;
c=sisa/a[i];
z=c+bunga;
total=z*a[i];
system("cls");
cout<<"|==================|"<<endl;
cout<<"| MOTOR SCORPION |"<<endl;
cout<<"|==================|\n"<<endl;
cout<<endl;
cout<<"\nSisa Pembayaran Sejumlah : Rp. "<<sisa<<endl;
cout<<"\nDiangsur Sebanyak : "<<a[i]<<" Kali/Bulan"<<endl;
cout<< "-----------------------------------------------------"<<endl;
cout<<"\nAngsuran Yang Harus Dibayar Per-Bulan : Rp. "<<z<<endl;
cout<<"\nTotal Angsuran Yang Harus Dibayar : Rp. "<<total;
konfirmasi();
i++;
}
int mio()
{
merk_motor[i]==1;
harga=15000000;
strcpy(motor[i],"MIO");
system("cls");
cout<<endl;
cout<<endl;
cout<<"|======================================|"<<endl;
cout<<"| MOTOR TIGER : Rp. 15.000.000 |"<<endl;
cout<<"|======================================|\n"<<endl;
data();
cout<< "-----------------------------------------------------"<<endl;
do{
cout<<"Berapa Uang Muka Yang Anda Inginkan : Rp. ";cin>>dp[i];
u_k = dp[i] - 15000000;
if (dp[i] > 15000000)
{
cout <<"\t---UANG MUKA ANDA MELAMPAUI HARGA MOTOR--- !!!\n\n"<<endl;
cout <<"\t---BAWA PULANG SAJA ITU MOTOR--- !!! \n\n";
}
else if (dp[i] < 15000000 )
{
sisa=15000000-dp[i];
cout<<"\nSisa Pembayaran Sejumlah : Rp. "<<sisa<<endl;
}
}while(dp[i] > 15000000);
do{
cout<<"\nBerapa Kali Angsuran Yang Anda Inginkan(Per-bulan): "; cin>>a[i];
bln = a[i] - 36 ;
if ( a[i] > 36 )
{
cout <<"\n\t---ANDA MELAMPAUI BATAS CICILAN PER BULAN--- !!!\n\n"<<endl;
}
else if ( a[i] < 36 )
{
cout<<"-----------------------------------------------------"<<endl;
}
}while(a[i] > 36);
bunga=sisa*6/100;
c=sisa/a[i];
z=c+bunga;
total=z*a[i];
system("cls");
cout<<"|=============|"<<endl;
cout<<"| MOTOR MIO |"<<endl;
cout<<"|=============|\n"<<endl;
cout<<endl;
cout<<"\nSisa Pembayaran Sejumlah : Rp. "<<sisa<<endl;
cout<<"\nDiangsur Sebanyak : "<<a[i]<<" Kali/Bulan"<<endl;
cout<< "-----------------------------------------------------"<<endl;
cout<<"\nAngsuran Yang Harus Dibayar Per-Bulan : Rp. "<<z<<endl;
cout<<"\nTotal Angsuran Yang Harus Dibayar : Rp. "<<total;
konfirmasi();
i++;
}
int cetak()
{
system("cls");
cout<<"DAFTAR PENGKREDIT MOTOR\n";
cout<<"PT. IKAFI\n";
cout<<"-----------------------------------------------------------------------------\n";
cout<<"No. NAMA\t No. KTP \t Merk Motor \t Uang Muka \tLama Angsur \n";
cout<<"-----------------------------------------------------------------------------\n";
for(int m=0;m<=batas;m++)
{
cout<<m+1<<".";
cout<<nama[m];
cout<<nik[m];
cout<<motor[m];
cout<<"Rp. "<<dp[m];
cout<<a[m]<<" Bulan";
cout<<"\n -----------------------------------------------------------------------------\n";
}
char lagi;
cout<<"\n\nApakah Anda Ingin Kredit Lagi (y/t) ? : ";cin>>lagi;
if ((lagi == 'Y')|| (lagi=='y'))
{
batas++;
i++;
menu();
}
else{
system("cls");
cout<<endl<<endl;
cout<<"\t\t--------Selamat Datang Kembali---------\n";
cout<<"\t\t---Thank You for Using Our Programme----\n";
cout<<"\t\t--------Wassalamualikum Wr.Wb.-------\n";
_exit(0);
}
}
------------------------------------------------------------------------------------------------
Running programnya, maka akan muncul seperti dibawah ini
input
username : kahar
pass : 123
dan akan muncul tampilan berikut.
masukkan kode motor yang ingin di rental (1 .. 5) !
Demikian lah Contoh Program Penyewaan/Rental Motor Menggunakan Program C++, semoga membantu !
#makkobbi.
#codingbebas.