# include <iostream.h>
# include <stdio.h>
# include <math.h>
# include <conio.h>
# include <string.h>
struct data {
char kode[15];
char nama[30];
char pendidikan[15];
char keahlian[30];
} pgw[50];
void menu();
void isi();
void tambah();
void baca();
void main()
{
char pil='0';
while (pil!='4')
{
menu();
pil=getche();
switch(pil)
{
case'1':
isi();break;
case'2':
tambah();break;
case'3':
baca();break;
case'4':
break;
}
}
}
void menu()
{
clrscr();
gotoxy(25,5);cout<<"MENU DATA BUDIDARMA";
gotoxy(25,6);cout<<"-------------------------------------";
gotoxy(25,7);cout<<"[1]Input data dosen";
gotoxy(25,8);cout<<"[2]Input data mahasiswa";
gotoxy(25,9);cout<<"[3]Membaca Data dosen";
gotoxy(25,10);cout<<"[4]Membaca data mahasiswa";
gotoxy(25,11);cout<<"[5]Keluar program";
gotoxy(25,12);cout<<"------------------------------------";
gotoxy(25,13);cout<<"PILIHAN :";
}
void isi()
{
FILE *coba;
char gj[10];
float atof();
int i,n=0;
while(1)
{
clrscr();
gotoxy(35,5);cout<<"MEMASUKKAN DATA DOSEN";
gotoxy(35,6);cout<<"------------------------------------------";
gotoxy(35,7);cout<<"Kode Dosen :";
gets(pgw[n].kode);
if(strlen(pgw[n].kode)==0)
break;
gotoxy(35,8);cout<<"Nama :";
gets(pgw[n].nama);
gotoxy(35,9);cout<<"Pendidikan :";
cin>>pgw[n].pendidikan;
gotoxy(35,10);cout<<"keahlian :";
cin>>pgw[n].keahlian;
gotoxy(35,6);cout<<"--------------------------------------------";
n++;
}
coba=fopen("c:\\Pegawai.Dat","wb");
for(i=0;i<n;++i)
{
fwrite(&pgw[i],sizeof(pgw[i]),1,coba);
}
fclose(coba);
}
void tambah()
{
FILE *coba;
char gj[10];
float atof();
int i,n=0;
while(1)
{
clrscr();
gotoxy(35,5);cout<<"MENAMBAH DATA Dosen";
gotoxy(35,6);cout<<"------------------------------------";
gotoxy(35,7);cout<<"Kode dosen :";
gets(pgw[n].kode);
if(strlen(pgw[n].kode)==0)
break;
gotoxy(35,8);cout<<"Nama :";
gets(pgw[n].nama);
gotoxy(35,9);cout<<"Pendidikan :";
cin>>pgw[n].pendidikan;
gotoxy(35,10);cout<<"Keahlian :";
cin>>pgw[n].keahlian;
gotoxy(35,6);cout<<"---------------------------------------";
n++;
}
coba=fopen("c:\\Pegawai.Dat","ab");
for(i=0;i<n;++i)
{
fwrite(&pgw[i],sizeof(pgw[i]),1,coba);
}
fclose(coba);
}
void baca()
{
FILE *coba;
int i=0,n=0;
clrscr();
coba=fopen("c:\\Pegawai.Dat","rb");
if(coba==NULL)
{
gotoxy(20,10);cout<<"File PEGAWAI.Dat belum ada";
gotoxy(20,12);cout<<"Tekan sembarang Tombol";
getch();
return;
}
gotoxy(5,1);cout<<"LAPORAN DATA PEGAWAI STMIK BUDIDARMA";
gotoxy(5,2);cout<<"----------------------------------------";
gotoxy(5,3);cout<<"NO KODE NAMA PENDIDIKAN KEAHLIAN ";
gotoxy(5,4);cout<<"----------------------------------------";
while((fread(&pgw[n],sizeof(pgw[n]),1,coba))==1)
{
i++;
gotoxy(6,4+i);cout<<i;
gotoxy(10,4+i);cout<<pgw[n].kode;
gotoxy(19,4+i);cout<<pgw[n].nama;
gotoxy(50,4+i);cout<<pgw[n].pendidikan;
gotoxy(60,4+i);cout<<pgw[n].keahlian;
}
gotoxy(5,5+i);cout<<"--------------------------------------Design HERIANTI LUSIA SIMBOLO";
getch();
fclose(coba);
}
Tidak ada komentar:
Posting Komentar