#include <iostream.h>
#include <string.h>
#include <stdlib.h>
int main()
{
// Deklarasi Variable
char inpmenu, inp[4], any;
int st, stat, x, y;
char nama[6] = {' '};
// Dumping Data CD
char cd[10][4] = { {'C','P','0','1'}, {'C','P','0','2'},
{'C','P','0','3'}, {'C','P','0','4'},
{'C','P','0','5'}, {'C','P','0','6'},
{'C','P','0','7'}, {'C','P','0','8'},
{'C','P','0','9'}, {'C','P','1','0'}
};
// Dumping Data Peminjaman
char pinjam[10][10] = {
{'C','P','0','1','H','a','t','m','a'} ,
{'C','P','0','2',' ',' ',' ',' ',' ',' '},
{'C','P','0','3','M','a','y','a','n','g'},
{'C','P','0','4',' ',' ',' ',' ',' ',' '},
{'C','P','0','5',' ',' ',' ',' ',' ',' '},
{'C','P','0','6',' ',' ',' ',' ',' ',' '},
{'C','P','0','7','A','i','n','a'},
{'C','P','0','8',' ',' ',' ',' ',' ',' '},
{'C','P','0','9',' ',' ',' ',' ',' ',' '},
{'C','P','1','0',' ',' ',' ',' ',' ',' '}
};
// Menu Label
menu :
// Clear Screen
system("clear");
// Greeting
cout << "+-----------------------------------+" << endl;
cout << "| Sistem Rental CD - Lite Edition |" << endl;
cout << "+-----------------------------------+" << endl << endl;
// Menu
cout << "Silakan pilih proses yang akan dilakukan" << endl;
cout << "1. Transaksi Peminjaman" << endl;
cout << "2. Transaksi Pengembalian" << endl;
cout << "3. Lihat Data CD" << endl;
cout << "0. Keluar Sistem" << 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 CD - Lite Edition |" << endl;
cout << "| Transaksi Peminjaman |" << endl;
cout << "+-----------------------------------+" << endl << endl;
// Input Kode CD
pinjam :
cout << "Masukkan kode CD : ";
cin >> inp;
// Validasi Input - Check Apa CD 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(!) CD tidak tersedia, sedang dalam peminjaman\n" << endl; goto pinjam; }
else
{
cout << "\nCD tersedia, dapat dipinjam\n" << endl;
cout << "Masukkan nama peminjam : ";
cin >> nama; cout << endl;
for (int z = 0; z<6 ; z++)
{
pinjam[x][z+4] = nama[z];
}
stat=1;
x=1;
}
}
x++;
if (x==10)
{ cout << "\n(!) Kode CD 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 << "Press any key + enter to continue .. ";
cin >> any; goto menu;
break;
case '2' :
// Clear Screen
system("clear");
// Greeting
cout << "+-----------------------------------+" << endl;
cout << "| Sistem Rental CD - Lite Edition |" << endl;
cout << "| Transaksi Pengembalian |" << endl;
cout << "+-----------------------------------+" << endl << endl;
// Input Kode CD
kembali :
cout << "Masukkan kode CD : ";
cin >> inp;
// Validasi Input - Check Apa CD 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(!) CD 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 CD 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 << "\nPress any key + enter to continue .. ";
cin >> any; goto menu;
break;
case '3' :
// Clear Screen
system("clear");
// Greeting
cout << "+-----------------------------------+" << endl;
cout << "| Sistem Rental CD - Lite Edition |" << endl;
cout << "| Data CD |" << endl;
cout << "+-----------------------------------+" << endl << endl;
// Tampilkan data peminjaman
for (int m=0; m<10; 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<10; n++)
{
cout << pinjam[m][n];
}
cout << endl;
}
else
{
cout << " o ";
for (int n=0; n<4; n++)
{
cout << pinjam[m][n];
}
cout << " masih tersedia" << endl;
}
}
cout << endl;
// Press any key to continue
cout << "Press any key + enter to continue .. ";
cin >> any; goto menu;
break;
case '0' :
// Clear Screen
system("clear");
// Greeting
cout << "+-----------------------------------+" << endl;
cout << "| Sistem Rental CD - Lite Edition |" << endl;
cout << "| Selesai |" << endl;
cout << "+-----------------------------------+" << endl << endl;
cout << "Terima kasih Anda telah menggunakan\nSistem Rental CD - Lite Edition.\n\n" << endl;
break;
default : goto menu;
}
}
Cara Menghilangkan Tanda Panah pada Shourtcut
14 tahun yang lalu
Tidak ada komentar:
Posting Komentar