system informasi rental mobil sederhana C++
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
class mobil
{
private:
char merk[20];
int harga_sewa;
public:
void data(char *Merk, int Harga_sewa)
{
strcpy(merk,Merk);
harga_sewa=Harga_sewa;
}
void tampil()
{
cout << "Merk mobil = " << merk << endl;
cout << "Harga sewa mobil/hari = " << harga_sewa << endl;
}
};
mobil mercy, avanza, innova, APV, taruna, xenia;
int main()
{
// Deklarasi Variable
char inpmenu,inp[4], any;
int st, stat, x, y,z,b,m,n;
char nama[12] = {' '};
// Dumping Data plat mobil
char cd[6][4] = { {'E','1','2','3'},{'E','2','3','4'},
{'E','3','4','5'}, {'E','4','5','6'},
{'E','5','6','7'}, {'E','6','7','8'}
};
// Dumping Data Peminjaman
char pinjam[6][16] = { {'E','1','2','3',' ',' ',' ',' ',' '} ,
{'E','2','3','4',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '},
{'E','3','4','5',' ',' ',' ',' ',' '},
{'E','4','5','6',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '},
{'E','5','6','7',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '},
{'E','6','7','8',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}
};
// Menu Label
menu :
// Clear Screen
clrscr();
// Greeting
cout << "+====================================+" << endl;
cout << " Sistem Rental Mobil " << endl;
cout << " dibuat oleh : R.Radian Baratasena " << endl;
cout << " NRP : 14511069 " << endl;
cout << "+====================================+" << endl << endl;
// Menu
cout << "Silakan masukkan pilihan Anda :" << endl;
cout << "1. Transaksi Peminjaman" << endl;
cout << "2. Transaksi Pengembalian" << endl;
cout << "3. Data Mobil" << endl;
cout << "4. Rekapitulasi" << endl;
cout << "5. Keluar" << endl;
// Input Menu
cout << "\n>> Pilihan Anda : ";
cin >> inpmenu;
cout << endl;
//inpmenu adalah masukkan untuk memilih menu yang akan dijalankan.
switch(inpmenu)
{
case '1' :
// Clear Screen
clrscr();
// Greeting, jika kita memilih '1' maka muncul tampilan 'Transaksi peminjaman'
cout << "+====================================+" << endl;
cout << " Sistem Rental Mobil " << endl;
cout << " Transaksi Peminjaman " << endl;
cout << "+====================================+" << endl << endl;
// Input Kode Mobil
pinjam :
cout << "Masukkan Kode Mobil : ";
cin >> inp;
//inp sebagai masukkan kode mobil
// Validasi Input - Check Apa Mobil Tersedia
x = 0; st = 0;
do
{
for (y=0; y<4; y++)
{
if (inp[y]==pinjam[x][y])
{ st++; }
else
{ st = 0; }
}
if (st==4)
{ if (pinjam[x][4]!=' ')
{ cout << "\n(!) Mobil sedang dipinjam\n" << endl;
getch();
goto menu; }
else
{
cout << "\nMobil tersedia, dapat dipinjam\n" << endl;
cout << "Masukkan nama peminjam : ";
cin >> nama; cout << endl;
for (z = 0; z<11 ; z++)
{
pinjam[x][z+4] = nama[z];
}
stat=1;
x=1;
}
}
x++;
if (x==9)
{ cout << "\n(!) Kode Mobil tidak ditemukan\n" << endl;
getch();
goto menu; }
} while (stat!=1);
// Clearing variable
stat=0; x=0;
for (b=0; b<6; b++)
{ nama[b] = ' '; }
// Press any key to continue
press : cout << "Tekan sembarang tombol melanjutkan .. ";
getch();
goto menu;
break;
case '2' :
// Clear Screen
clrscr();
// Greeting, jika memilih '2' maka akan muncul tampilan 'Transaksi pengembalian.
cout << "+====================================+" << endl;
cout << " Sistem Rental Mobil " << endl;
cout << " Transaksi Pengembalian " << endl;
cout << "+====================================+" << endl << endl;
// Input Kode Mobil
kembali :
cout << "Masukkan kode Mobil : ";
cin >> inp;
// Validasi Input - Check Apa Mobil Tersedia
x = 0; st = 0;
do
{
for (y=0; y<4; y++)
{
if (inp[y]==pinjam[x][y])
{ st++; }
else
{ st = 0; }
}
if (st==4)
{ if (pinjam[x][4]==' ')
{ cout << "\n(!) Mobil tersebut belum dipinjam\n" << endl;
getch();
goto menu; }
else
{
for (z = 0; z<6 ; z++)
{
pinjam[x][z+4] = ' ';
}
stat=1;
x=1;
}
}
x++;
if (x==9)
{ cout << "\n(!) Kode Mobil tidak ditemukan\n" << endl;
getch();
goto menu; }
} while (stat!=1);
cout << "\nTransaksi pengembalian berhasil" << endl;
// Clearing variable
stat=0; x=0;
for (b=0; b<6; b++)
{ nama[b] = ' '; }
// Press any key to continue
press2 : cout << "\nTekan sembarang tombol untuk melanjutkan .. ";
getch();
goto menu;
break;
case '3' :
// Clear Screen
clrscr();
// Greeting
cout << "+====================================+"<< endl;
cout << " Sistem Rental Mobil " << endl;
cout << " Data Mobil " << endl;
cout << "+====================================+" << endl << endl;
//pemanggilan class mobil
mercy.data("Mercedes Benz ", 1000000);
avanza.data("Avanza ", 250000);
innova.data("Kijang Innova ",350000);
APV.data("APV ", 250000);
taruna.data("Taruna ", 200000);
xenia.data("Xenia ", 250000);
mercy.tampil();cout<<endl;
avanza.tampil();cout<<endl;
innova.tampil();cout<<endl;
APV.tampil();cout<<endl;
taruna.tampil();cout<<endl;
xenia.tampil();cout<<endl;
// Press any key to continue
press3 : cout << "\nTekan sembarang tombol untuk melanjutkan .. ";
getch();
goto menu;
break;
case '4' :
// Clear Screen
clrscr();
// Greeting, jika memilih '4' maka akan muncul tampilan 'Rekapitulasi'
cout << "+====================================+" << endl;
cout << " Sistem Rental Mobil " << endl;
cout << " Rekapitulasi " << endl;
cout << "+====================================+" << endl << endl;
// Tampilkan data peminjaman
for (m=0; m<6; m++)
{
if (pinjam[m][4]!=' ')
{
cout << " X ";
for (n=0; n<4; n++)
{
cout << pinjam[m][n];
}
cout << " dipinjam oleh ";
for (n=4; n<16; n++)
{
cout << pinjam[m][n];
}
cout << endl;
}
else
{
cout << " V ";
for (n=0; n<4; n++)
{
cout << pinjam[m][n];
}
cout << " masih tersedia" << endl;
}
}
cout << endl;
// Press any key to continue
cout << "Tekan sembarang tombol untuk melanjutkan .. ";
getch();
goto menu;
break;
case '5' :
// Clear Screen
clrscr();
// Greeting, jika memilih '5' maka akan muncul tampilan keluar dari program.
cout << "+=====================================+" << endl;
cout << " Sistem Rental Mobil " << endl;
cout << " Selesai " << endl;
cout << " maju terus STIKOM POLTEK Cirebon " << endl;
cout << "+=====================================+" << endl << endl;
cout << "Terima kasih Anda telah menggunakan\nSistem Rental Mobil.\n\n" << endl;
getch();
break;
default : goto menu;
}
}
Comments
Post a Comment