Contoh Program >>>
#include <stdio.h>>>> KLIK DOWNLOAD <<<
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <iostream>
using namespace std;
int main(){
system ("color a");
typedef struct{
char pemilik[20];
}PML;
int box[5];
int menu2;
char cari[20];
int no;
int cek;
int f,i,j;
PML data[20];
system("cls");
for (i=0; i<5; i++){
box[i]=0;
}
for (i=0; i<5; i++){
strcpy(data[i].pemilik,"kosong");
}
do{
printf("======================================\n");
printf("| PEMESANAN KURSI BUS | \n");
printf("| Crated By.Bagycb | \n");
printf("======================================\n");
printf("\n");
printf("\n=======================\n");
if(strcmp(data[i].pemilik,"kosong")==0){
box[i]=0; //awas
}else{
box[i]=1;
}
for (i=0; i<5; i++){
printf("[%d] ",box[i]);
}
printf("\n=======================\n");
for (i=0; i<5; i++){
printf(" %d ",i+1);
}
printf("\n\n");
printf(" 1. Lihat Pemilik Kursi \n");
printf(" 2. Pesan Kursi \n");
printf(" 3. Edit Pemilik Kursi \n");
printf(" 4. Edit Nomor Kursi \n");
printf(" 5. Batalkan Pemesanan \n");
printf(" 6. Exit \n");
printf("Masuka Pilihan : ");
scanf("%d", &menu2);
if(menu2 <= 6){
switch (menu2){
case 1 : {
system("cls");
printf("Lihat Pemilik Kursi \n");
printf("=======================\n");
for (i=0; i<5; i++){
printf("Nomor Kursi : %d\n",i+1);
printf("Pemilik : %s\n\n",data[i].pemilik);
}
system("pause");
system("cls");
}
break;
case 2 : {
system("cls");
printf("Pesan Kursi\n");
printf("=======================\n");
for (i=0; i<5; i++){
printf("[%d] ",box[i]);
}
printf("\n=======================\n");
for (i=0; i<5; i++){
printf(" %d ",i+1);
}
printf("\n");
printf("Pilih No. Kursi : ");
scanf("%d",&no);
i=no-1;
if (box[i]==0)
{
printf("Masukan Nama Anda : ");
fflush(stdin);gets(data[i].pemilik);
}
else
{
cout<<"Kursi Sudah Terisi";
}
printf("\nselesai !!\n");
system("pause");
system("cls");
}
break;
case 3 : {
system("cls");
printf("Edit Pemilik Kursi\n");
printf("=======================\n");
for (i=0; i<5; i++){
printf("[%d] ",box[i]);
}
printf("\n=======================\n");
for (i=0; i<5; i++){
printf(" %d ",i+1);
}
printf("\n\n");
printf("Pilih No. Kursi : ");
scanf("%d",&no);
j=no-1;
if(box[j]==0){
printf("Maaf, kursi yang anda pilih belum dipesan\n");
}else if(box[j]==1){
printf("Masukan Nama Anda : ");
fflush(stdin);gets(data[j].pemilik);
}
printf("\nselesai !!\n");
system("pause");
system("cls");
}
break;
case 4 : {
system("cls");
printf("Edit No. Kursi\n");
printf("=======================\n");
printf("Masukan Nama Anda : ");
fflush(stdin);gets(cari);
for (i=0; i<5; i++){
if (strcmp(data[i].pemilik,cari)==0){
f=i;
cek=0;
}
}
if(cek==0){
box[i=0];
printf("Ubah No. Kursi ke : ");
scanf("%d",&no);
i=no-1;
strcpy(data[i].pemilik,cari);
strcpy(data[f].pemilik,"kosong");
box[f]=0;
}else{
printf("Maaf nama pemilik tidak ditemukan \n");
}
system("pause");
system("cls");
}
break;
case 5 : {
system("cls");
printf("Batalkan Pemesanan \n");
printf("=======================\n");
for (i=0; i<5; i++){
printf("[%d] ",box[i]);
}
printf("\n=======================\n");
box[i]=1;
printf("\n\n");
printf("Pilih No. Kursi : ");
scanf("%d",&no);
i=no-1;
box[i]=box[i]-1;
strcpy(data[i].pemilik,"kosong");
system("pause");
system("cls");
}
break;
default :
break;
}
}else{
printf("Pilihan Tidak ada!\n");
system("pause");
system("cls");
}
}while ((menu2==0) || (menu2 != 6));
system("pause");
system("cls");
return 0;
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This comment has been removed by the author.
ReplyDeleteMakasih banyak gan 😀
ReplyDeletekak kalau gunanya PML itu untuk apa ya? terimakasih banyak kak.
ReplyDelete