#include <iostream>
using namespace std;
int main(){
int
antrian[]={0,0,0,0,0};
int menu,
properties;
char
konfirmasi;
cout <<
"================== MENU PILIHAN ANTRIAN BIOSKOP =================="
<< endl;
cout <<
"== 1. Push / Masukkan Data =="
<< endl;
cout <<
"== 2. Pop / Keluarkan Data =="
<< endl;
cout <<
"== 3. Tampilkan Data
==" << endl;
cout <<
"== 4. Bersihkan Data
==" << endl;
cout <<
"== 5. Keluar Program
==" << endl;
cout <<
"==============================================================="
<< endl;
cout << "Syarat dan Ketentuan
Berlaku : " << endl;
cout <<
"- Data Maksimal 5 " << endl;
cout <<
"- Data Masukan Harus Berupa Angka selain 0 (nol) " << endl;
cout <<
"==============================================================="
<< endl;
properties = 0;
while
(properties == 0){
cout
<< "pilihan menu = ";
cin
>> menu;
switch
(menu) {
case 1
: if(antrian[0] != 0){
cout <<
"Maaf data antrian penuh, Anda tidak bisa melakukan PUSH" <<
endl;
cout <<
"=========================================================="
<<endl;
} else {
for (int an=4 ;
an>=0 ; an--){
if (antrian[an]
== 0){
cout
<< "Masukkan Angka = ";
cin
>> antrian[an];
cout
<< "=========================================================="
<<endl;
break;
}
}
}
break;
case 2
: if(antrian[4] == 0){
cout << "Maaf
data antrian kosong, Anda tidak bisa melakukan POP" << endl;
cout <<
"=========================================================="
<<endl;
} else {
int dataAkhir;
dataAkhir =
antrian[4];
for (int an=4 ;
an>=1 ; an--){
antrian[an] =
antrian[an-1];
}
antrian[0] = 0;
cout <<
"Data yang dikeluarkan adalah = " << dataAkhir <<endl;
cout <<
"=========================================================="
<<endl;
}
break;
case 3
: cout << "Data yang ada
dalam antrian adalah = " << endl;
for(int as=0 ; as<=4 ; as++){
cout <<
"Data ke-" << as;
cout <<
" adalah = " << antrian[as] << endl;
}
cout <<
"=========================================================="
<<endl;
break;
case 4
: if(antrian[4] == 0){
cout <<
"Maaf data antrian kosong, Tidak ada data yang akan dihapus" <<
endl;
cout <<
"=========================================================="
<<endl;
} else {
cout <<
"Data yang ada dalam antrian akan dihapus, Apakah yakin (Y/N) = "
<< endl;
cin >>
konfirmasi;
if (konfirmasi ==
'Y' || konfirmasi == 'y'){
for(int as=0 ;
as<=4 ; as++){
antrian[as] = 0;
}
cout <<
"Data telah terhapus !" << endl;
cout <<
"==========================================================" <<endl;
}
}
break;
case 5
: properties = 1;
cout << "" << endl;
cout << "
========= $$$$$$$$$$$$$$$$$$$$$$$$$$ =========" << endl;
cout << " ===
===" << endl;
cout << "=== Anda
telah keluar dari program antrian FIFO
===" << endl;
cout << "=== Terima Kasih ===" << endl;
cout << " ===
===" << endl;
cout << "
========= ^^^^^^^^^^^^^^^^^^^^^^^^^^^ =========" << endl;
break;
default
: cout << "Maaf pilihan Anda
tidak ada dalam Menu" <<endl;
break;
}
}
return 0;
}
Tidak ada komentar:
Posting Komentar