#include <iostream.h>
#include <stdio.h>
#include <conio.h>
#include<string.h>
main (void)
{
char username[20];
int password;
int i;
cout << "||-------------------------------------------------||\n";
cout << "|| Silahkan Login terlebih dahulu ||\n";
cout << "||-------------------------------------------------||\n\n";
char user[20];
char pass[20];
i = 1;
do
{
cout << "\n\nMasukkan Username anda : ";
cin >> user;
cout << "Masukkan Password anda : ";
cin >> pass;
cout<< "\n__ Created by Mrs. Eko\n";
if (strcmp(user,"Eko") ==0 && strcmp(pass,"113028") ==0)
{
cout << "\n_________________________\n";
cout << " Login Berhasil " << endl;
cout << " _________________________\n\n";
cout<<" Tekan ENTER untuk Lanjutkan \n\n";
getch();
typedef struct pasien{
int no;
char nama[20];
char penyakit[20];
char obat[20];
};
void selection ( int no[],char nama[20],char penyakit[20],char obat[20]);
pasien data[10];
int i,n,x;
int found;
int z;
char pil1;
int g = 1;
do
{
//clrscr();
cout<<"____________________________________"<<endl;
cout<<" MENU PROGAM DATABASE APOTEK "<<endl;
cout<<"____________________________________"<<endl;
cout<<" "<<endl;
cout<<" 1. Input Data "<<endl;
cout<<" 2. Cari Data "<<endl;
cout<<" 3. Edit Data "<<endl;
cout<<" 4. Hapus Data "<<endl;
cout<<" 5. Lihat Data "<<endl;
cout<<" 6. Keluar "<<endl;
cout<<" "<<endl;
cout<<endl;
cout<<"Masukkan Pilihan Anda :";
cin>>z;
cout<<endl;
//clrscr();
switch(z)
{
case 1:
printf(" Masukan jumlah data = ");
scanf("%d",&n);
i=n;
for(i=0;i<n;i++)
{
cout<<"\t _____________________"<<endl;
cout<<"\t MENU INPUT DATA"<<endl;
cout<<"\t _____________________"<<endl;
cout<<"MASUKKAN DATA KE "<<g<<endl;
cout<<"\t Nomor Pasien :";
cin>>data[g].no;
cout<<"\t Nama Pasien :";
cin>>data[g].nama;
cout<<"\t Penyakit Pasien :";
cin>>data[g].penyakit;
cout<<"\t Nama Obat :";
cin>>data[g].obat;
cout<<endl;
g++;
}
break;
case 2:
int cari; int j;
// clrscr();
printf("\n\n\n");
printf("Menu Pencarian Data\n");
for(i=0;i<n;i++)
{
printf("\n\nData ke %d\n",i+1);
printf("Nomor Pasien : %d\n",data[i].no);
}
printf("\n+++++++++++++++++++++++++\n");
do{
printf("\n Nomor Pasien yang akan dicari : ");
scanf("%d",&cari);
i=0;
while((i<n)&(!found))
{
if(data[i].no==cari)
i=i+1;
}
if(found)
{
printf("\n Data dengan Nomor Pasien %d terdapat dalam Progam \n",cari);
printf("\n________________________________\n");
printf("Nomor Pasien : %d\n",data[i].no);
printf("Nama Pasien : %s\n",data[i].nama);
printf("Penyakit Pasien : %s\n",data[i].penyakit);
printf("Nama Obat : %s\n",data[i].obat);
cout<<endl;
}
else{
printf("\n Data dengan NomorPasien %d tidak terdapat pada progam\n",cari);
}
printf("\n_____________________________________\n");
printf("Cari lagi? [y/t] : ");
pil1=getche();
}
while(pil1=='Y'||pil1=='y');
break;
case 3:
int edit;
cout<<"\t ______________________________"<<endl;
cout<<"\t ++ MENU EDIT DATA ++" <<endl;
cout<<"\t ______________________________"<<endl;
cout<<"\t ++ Data Baru"<<endl;
for(i=0;i<n;i++)
{
cout<<"\t______________________________________"<<endl;
cout<<"\t Data ke "<<i+1<<endl;
cout<<"\t Nomor Pasien : "<<data[i].no<<endl;
cout<<"\t Nama Pasien : "<<data[i].nama<<endl;
cout<<"\t Penyakit Pasien: "<<data[i].penyakit<<endl;
cout<<"\t Nama Obat : "<<data[i].obat<<endl;
cout<<"\t _____________________________________"<<endl;
cout<<endl;
}
cout<<endl;
cout<<"\t Data Ke Berapa yang akan di Edit : ";
cin>>edit;
for(i=0;i<n;i++){
if(i==edit-1){
cout<<"\t___________________________________"<<endl;
cout<<"\t Data ke "<<i+1<<endl;
cout<<"\t Nomor Pasien : "<<data[i].no<<endl;
cout<<"\t Nama Pasien : "<<data[i].nama<<endl;
cout<<"\t Penyakit Pasien: "<<data[i].penyakit<<endl;
cout<<"\t Nama Obat : "<<data[i].obat<<endl;
cout<<"Masukan Data Yang Baru : "<<endl;
cout<<"\t Masukkan Nomor Pasien :";
cin>>data[i].no;
cout<<"\t Masukkan Nama Pasien :";
cin>>data[i].nama;
cout<<"\t Masukkan Penyakit Pasien:";
cin>>data[i].penyakit;
cout<<"\t Masukkan Nama obat :";
cin>>data[i].obat;
cout<<endl<<"\t ______________________________";
cout<<endl;
}
}
break;
case 4:
int hapus;
// clrscr();
for(i=0;i<n;i++){
cout<<"\t _______________________________________"<<endl;
cout<<"\t Data ke "<<i+1<<endl;
cout<<"\t Nomor Pasien : "<<data[i].no<<endl;
cout<<"\t Nama Pasien : "<<data[i].nama<<endl;
cout<<"\t Penyakit Pasien: "<<data[i].penyakit<<endl;
cout<<"\t Nama Obat : "<<data[i].obat<<endl;
cout<<"\t______________________________________"<<endl;
}
cout<<" \t \n Data Ke berapa yang ingin dihapus:";
cin>>hapus;
cout<<"\t Data yang Baru \n ";
for(n=hapus-1;n<i-1;n++){
data[x]=data[i-1];
}
for (n=0;n<i-1;n++)
{
cout<<"\t_______________________________"<<endl;
cout<<"\t Data ke "<<n+1<<endl;
cout<<"\t Nomor Pasien : "<<data[n].no<<endl;
cout<<"\t Nama Pasien : "<<data[n].nama<<endl;
cout<<"\t Penyakit Pasien: "<<data[n].penyakit<<endl;
cout<<"\t Nama Obat : "<<data[n].obat<<endl;
cout<<"\t _________________________________"<<endl;
cout<<endl;
}
break;
case 5:
cout<<"\n Menu Menampilkan Data ";
for(i=0;i<n;i++){
cout<<"\t________________________________"<<endl;
cout<<"\t Data ke "<<i+1<<endl;
cout<<"\t Nomor Pasien : "<<data[i].no<<endl;
cout<<"\t Nama Pasien : "<<data[i].nama<<endl;
cout<<"\t Penyakit Pasien: "<<data[i].penyakit<<endl;
cout<<"\t Nama Obat : "<<data[i].obat<<endl;
cout<<"\t ________________________________"<<endl;
}
break;
case 6:
cout<<" Anda Telah Keluar Dari Program ini \n";
cout<<"\n _____ Terima Kasih_____\n";
cout<<"|| _____________________________ ||"<<endl;
}
cout<<endl<<"Lanjutkan Ke Menu Utama [Y/N] :";
cin>>pil1;
cout<<"\n Anda Tidak lagi melanjutkan Program ini \n";
cout<<"\n _________________ Terima Kasih______________\n";
cout<<"________________________________________"<<endl;
}
while (pil1=='y' || pil1=='Y');
return 0;
getch();
}
else
{
cout << "\n||_______________________________________||\n";
cout << " || Maaf USERNAME & PASSWORD Anda Salah! ||" << endl;
cout << " ||_______________________________________||\n\n";
i = i +1;
}
}
while (i <= 3);
cout << "Anda Telah 3x Memasukan USERNAME & PASSWORD Yang Salah\n";
cout << "Mohon Maaf Akun Anda Kami Blockir, Terima Kasih..";
getch();
}
#include <stdio.h>
#include <conio.h>
#include<string.h>
main (void)
{
char username[20];
int password;
int i;
cout << "||-------------------------------------------------||\n";
cout << "|| Silahkan Login terlebih dahulu ||\n";
cout << "||-------------------------------------------------||\n\n";
char user[20];
char pass[20];
i = 1;
do
{
cout << "\n\nMasukkan Username anda : ";
cin >> user;
cout << "Masukkan Password anda : ";
cin >> pass;
cout<< "\n__ Created by Mrs. Eko\n";
if (strcmp(user,"Eko") ==0 && strcmp(pass,"113028") ==0)
{
cout << "\n_________________________\n";
cout << " Login Berhasil " << endl;
cout << " _________________________\n\n";
cout<<" Tekan ENTER untuk Lanjutkan \n\n";
getch();
typedef struct pasien{
int no;
char nama[20];
char penyakit[20];
char obat[20];
};
void selection ( int no[],char nama[20],char penyakit[20],char obat[20]);
pasien data[10];
int i,n,x;
int found;
int z;
char pil1;
int g = 1;
do
{
//clrscr();
cout<<"____________________________________"<<endl;
cout<<" MENU PROGAM DATABASE APOTEK "<<endl;
cout<<"____________________________________"<<endl;
cout<<" "<<endl;
cout<<" 1. Input Data "<<endl;
cout<<" 2. Cari Data "<<endl;
cout<<" 3. Edit Data "<<endl;
cout<<" 4. Hapus Data "<<endl;
cout<<" 5. Lihat Data "<<endl;
cout<<" 6. Keluar "<<endl;
cout<<" "<<endl;
cout<<endl;
cout<<"Masukkan Pilihan Anda :";
cin>>z;
cout<<endl;
//clrscr();
switch(z)
{
case 1:
printf(" Masukan jumlah data = ");
scanf("%d",&n);
i=n;
for(i=0;i<n;i++)
{
cout<<"\t _____________________"<<endl;
cout<<"\t MENU INPUT DATA"<<endl;
cout<<"\t _____________________"<<endl;
cout<<"MASUKKAN DATA KE "<<g<<endl;
cout<<"\t Nomor Pasien :";
cin>>data[g].no;
cout<<"\t Nama Pasien :";
cin>>data[g].nama;
cout<<"\t Penyakit Pasien :";
cin>>data[g].penyakit;
cout<<"\t Nama Obat :";
cin>>data[g].obat;
cout<<endl;
g++;
}
break;
case 2:
int cari; int j;
// clrscr();
printf("\n\n\n");
printf("Menu Pencarian Data\n");
for(i=0;i<n;i++)
{
printf("\n\nData ke %d\n",i+1);
printf("Nomor Pasien : %d\n",data[i].no);
}
printf("\n+++++++++++++++++++++++++\n");
do{
printf("\n Nomor Pasien yang akan dicari : ");
scanf("%d",&cari);
i=0;
while((i<n)&(!found))
{
if(data[i].no==cari)
i=i+1;
}
if(found)
{
printf("\n Data dengan Nomor Pasien %d terdapat dalam Progam \n",cari);
printf("\n________________________________\n");
printf("Nomor Pasien : %d\n",data[i].no);
printf("Nama Pasien : %s\n",data[i].nama);
printf("Penyakit Pasien : %s\n",data[i].penyakit);
printf("Nama Obat : %s\n",data[i].obat);
cout<<endl;
}
else{
printf("\n Data dengan NomorPasien %d tidak terdapat pada progam\n",cari);
}
printf("\n_____________________________________\n");
printf("Cari lagi? [y/t] : ");
pil1=getche();
}
while(pil1=='Y'||pil1=='y');
break;
case 3:
int edit;
cout<<"\t ______________________________"<<endl;
cout<<"\t ++ MENU EDIT DATA ++" <<endl;
cout<<"\t ______________________________"<<endl;
cout<<"\t ++ Data Baru"<<endl;
for(i=0;i<n;i++)
{
cout<<"\t______________________________________"<<endl;
cout<<"\t Data ke "<<i+1<<endl;
cout<<"\t Nomor Pasien : "<<data[i].no<<endl;
cout<<"\t Nama Pasien : "<<data[i].nama<<endl;
cout<<"\t Penyakit Pasien: "<<data[i].penyakit<<endl;
cout<<"\t Nama Obat : "<<data[i].obat<<endl;
cout<<"\t _____________________________________"<<endl;
cout<<endl;
}
cout<<endl;
cout<<"\t Data Ke Berapa yang akan di Edit : ";
cin>>edit;
for(i=0;i<n;i++){
if(i==edit-1){
cout<<"\t___________________________________"<<endl;
cout<<"\t Data ke "<<i+1<<endl;
cout<<"\t Nomor Pasien : "<<data[i].no<<endl;
cout<<"\t Nama Pasien : "<<data[i].nama<<endl;
cout<<"\t Penyakit Pasien: "<<data[i].penyakit<<endl;
cout<<"\t Nama Obat : "<<data[i].obat<<endl;
cout<<"Masukan Data Yang Baru : "<<endl;
cout<<"\t Masukkan Nomor Pasien :";
cin>>data[i].no;
cout<<"\t Masukkan Nama Pasien :";
cin>>data[i].nama;
cout<<"\t Masukkan Penyakit Pasien:";
cin>>data[i].penyakit;
cout<<"\t Masukkan Nama obat :";
cin>>data[i].obat;
cout<<endl<<"\t ______________________________";
cout<<endl;
}
}
break;
case 4:
int hapus;
// clrscr();
for(i=0;i<n;i++){
cout<<"\t _______________________________________"<<endl;
cout<<"\t Data ke "<<i+1<<endl;
cout<<"\t Nomor Pasien : "<<data[i].no<<endl;
cout<<"\t Nama Pasien : "<<data[i].nama<<endl;
cout<<"\t Penyakit Pasien: "<<data[i].penyakit<<endl;
cout<<"\t Nama Obat : "<<data[i].obat<<endl;
cout<<"\t______________________________________"<<endl;
}
cout<<" \t \n Data Ke berapa yang ingin dihapus:";
cin>>hapus;
cout<<"\t Data yang Baru \n ";
for(n=hapus-1;n<i-1;n++){
data[x]=data[i-1];
}
for (n=0;n<i-1;n++)
{
cout<<"\t_______________________________"<<endl;
cout<<"\t Data ke "<<n+1<<endl;
cout<<"\t Nomor Pasien : "<<data[n].no<<endl;
cout<<"\t Nama Pasien : "<<data[n].nama<<endl;
cout<<"\t Penyakit Pasien: "<<data[n].penyakit<<endl;
cout<<"\t Nama Obat : "<<data[n].obat<<endl;
cout<<"\t _________________________________"<<endl;
cout<<endl;
}
break;
case 5:
cout<<"\n Menu Menampilkan Data ";
for(i=0;i<n;i++){
cout<<"\t________________________________"<<endl;
cout<<"\t Data ke "<<i+1<<endl;
cout<<"\t Nomor Pasien : "<<data[i].no<<endl;
cout<<"\t Nama Pasien : "<<data[i].nama<<endl;
cout<<"\t Penyakit Pasien: "<<data[i].penyakit<<endl;
cout<<"\t Nama Obat : "<<data[i].obat<<endl;
cout<<"\t ________________________________"<<endl;
}
break;
case 6:
cout<<" Anda Telah Keluar Dari Program ini \n";
cout<<"\n _____ Terima Kasih_____\n";
cout<<"|| _____________________________ ||"<<endl;
}
cout<<endl<<"Lanjutkan Ke Menu Utama [Y/N] :";
cin>>pil1;
cout<<"\n Anda Tidak lagi melanjutkan Program ini \n";
cout<<"\n _________________ Terima Kasih______________\n";
cout<<"________________________________________"<<endl;
}
while (pil1=='y' || pil1=='Y');
return 0;
getch();
}
else
{
cout << "\n||_______________________________________||\n";
cout << " || Maaf USERNAME & PASSWORD Anda Salah! ||" << endl;
cout << " ||_______________________________________||\n\n";
i = i +1;
}
}
while (i <= 3);
cout << "Anda Telah 3x Memasukan USERNAME & PASSWORD Yang Salah\n";
cout << "Mohon Maaf Akun Anda Kami Blockir, Terima Kasih..";
getch();
}