#include <iostream.h>
#include <string.h>
#include <stdlib.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 avanza, innova, APV, krista, taruna, xenia;
int main()
{
// Deklarasi Variable
char inpmenu, inp[4], any;
int st, stat, x, y;
char nama[12] = {' '};
// Dumping Data CD
char cd[6][4] = { {'0','1','A','V'},{'0','2','I','N'},
{'0','3','A','P'}, {'0','4','K','R'},
{'0','5','T','A'}, {'0','6','X','E'}
};
// Dumping Data Peminjaman
char pinjam[6][16] = { {'0','1','A','V','H','a','t','m','a'} ,
{'0','2','I','N',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '},
{'0','3','A','P','R','i','r','i','z'},
{'0','4','K','R',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '},
{'0','5','T','A',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '},
{'0','6','X','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}
};
// Menu Label
menu :
// Clear Screen
system("clear");
// Greeting
cout << "+====================================+" << endl;
cout << " Sistem Rental Mobil " << 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;
// Casting Input Menu
switch(inpmenu)
{
case '1' :
// Clear Screen
system("clear");
// Greeting
cout << "+====================================+" << endl;
cout << " Sistem Rental Mobil " << endl;
cout << " Transaksi Peminjaman " << endl;
cout << "+====================================+" << endl << endl;
// Input Kode Mobil
pinjam :
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 sedang dipinjam\n" << endl; goto pinjam; }
else
{
cout << "\nMobil tersedia, dapat dipinjam\n" << endl;
cout << "Masukkan nama peminjam : ";
cin>>nama;
cout << endl;
for (int z = 0; z<11 ; z++)
{
pinjam[x][z+4] = nama[z];
}
stat=1;
x=1;
}
}
x++;
if (x==10)
{ cout << "\n(!) Kode Mobil tidak ditemukan\n" << endl; goto pinjam; }
} while (stat!=1);
// Clearing variable
stat=0; x=0;
for (int b=0; b<6; b++)
{ nama[b] = ' '; }
// Press any key to continue
press : cout << "Tekan sembarang tombol + enter untuk melanjutkan .. ";
cin >> any; goto menu;
break;
case '2' :
// Clear Screen
system("clear");
// Greeting
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; goto kembali; }
else
{
for (int z = 0; z<6 ; z++)
{
pinjam[x][z+4] = ' ';
}
stat=1;
x=1;
}
}
x++;
if (x==10)
{ cout << "\n(!) Kode Mobil tidak ditemukan\n" << endl; goto kembali; }
} while (stat!=1);
cout << "\nTransaksi pengembalian berhasil" << endl;
// Clearing variable
stat=0; x=0;
for (int b=0; b<6; b++)
{ nama[b] = ' '; }
// Press any key to continue
press2 : cout << "\nTekan sembarang tombol + enter untuk melanjutkan .. ";
cin >> any; goto menu;
break;
case '3' :
// Clear Screen
system("clear");
// Greeting
cout << "+====================================+" << endl;
cout << " Sistem Rental Mobil " << endl;
cout << " Data Mobil " << endl;
cout << "+====================================+" << endl << endl;
avanza.data("Avanza ", 400000);
innova.data("Kijang Innova ", 600000);
APV.data("APV ", 550000);
krista.data("Kijang Krista", 400000);
taruna.data("Taruna ", 300000);
xenia.data("Xenia ", 40000);
avanza.tampil();cout<<endl;
innova.tampil();cout<<endl;
APV.tampil();cout<<endl;
krista.tampil();cout<<endl;
taruna.tampil();cout<<endl;
xenia.tampil();cout<<endl;
// Press any key to continue
press3 : cout << "\nTekan sembarang tombol + enter untuk melanjutkan .. ";
cin >> any; goto menu;
break;
case '4' :
// Clear Screen
system("clear");
// Greeting
cout << "+====================================+" << endl;
cout << " Sistem Rental Mobil " << endl;
cout << " Rekapitulasi " << endl;
cout << "+====================================+" << endl << endl;
// Tampilkan data peminjaman
for (int m=0; m<6; m++)
{
if (pinjam[m][4]!=' ')
{
cout << " X ";
for (int n=0; n<4; n++)
{
cout << pinjam[m][n];
}
cout << " dipinjam oleh ";
for (int n=4; n<16; n++)
{
cout << pinjam[m][n];
}
cout << endl;
}
else
{
cout << " V ";
for (int n=0; n<4; n++)
{
cout << pinjam[m][n];
}
cout << " masih tersedia" << endl;
}
}
cout << endl;
// Press any key to continue
cout << "Tekan sembarang tombol + enter untuk melanjutkan .. ";
cin >> any; goto menu;
break;
case '5' :
// Clear Screen
system("clear");
// Greeting
cout << "+====================================+" << endl;
cout << " Sistem Rental Mobil " << endl;
cout << " Selesai " << endl;
cout << "+====================================+" << endl << endl;
cout << "Terima kasih Anda telah menggunakan\nSistem Rental Mobil.\n\n" << endl;
break;
default : goto menu;
}
}
Tidak ada komentar:
Posting Komentar