#include<iostream.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<conio.h>
#include<string.h>
struct budidarma {
char kode[5];
char nama[40], pend[15], ahli[30];
char npm[8], jenjang[2], tahun[4];
char jurusan[20];
}rbudidarma[10];
void menu();
void data_dosen();
void data_mhsw();
void output_ddosen();
void output_dmhsw();
void keluar();
void main (){
char pil='0';
while(pil !='6') {
menu();
pil=getch();
switch(pil){
case'1': data_dosen(); break;
case'2': data_mhsw(); break;
case'3': output_ddosen(); break;
case'4': output_dmhsw(); break;
case'5': keluar(); break;
}
}
}
void menu()
{
clrscr();
gotoxy(25,5); cout<<" MENU UTAMA ";
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] Output Data Dosen";
gotoxy(25,10); cout<<" [4] Output Data Mahasiswa";
gotoxy(25,11); cout<<" [5] Keluar Program";
gotoxy(25,12); cout<<" _______________________________";
gotoxy(25,13); cout<<" PILIHAN : ";
}
void data_dosen(){
FILE *coba;
float atof();
int i, n=0;
while(1)
{
clrscr();
gotoxy(35,5); cout<<" INFORMASI DATA DOSEN" ;
gotoxy(35,6); cout<<" _____________________________ " ;
gotoxy(35,7); cout<<"KODE DOSEN[A, B, C] :";
gets(rbudidarma[n].kode);
gotoxy(35,8); cout<<"NAMA DOSEN :";
cin>>rbudidarma[n].nama;
gotoxy(35,9); cout<<"Pendidikan [S1, S2, Master] :";
gets(rbudidarma[n].pend);
gotoxy(35,10); cout<<"Keahlian:";
cin>>rbudidarma[n].ahli;
gotoxy(35,12); cout<<" .............................. " ;
++i;
}
gotoxy(35,6); cout<<" .............................. " ;
++i;
}
coba=fopen("c:\\budidarma.Dat","wb");
for (i=0; i<n; ++i)
{
fwrite(&rbudidarma[i], sizeof(rbudidarma[i]),1,coba);
fclose(coba);
}
void data_mhsw(){
FILE *coba;
float atof();
int i, n=0;
while(1)
{
clrscr();
gotoxy(35,5); cout<<" INFORMASI DATA MAHASISWA" ;
gotoxy(35,6); cout<<" _____________________________ " ;
gotoxy(35,7); cout<<"NPM : ";
cin>>rbudidarma[n].npm;
gotoxy(35,8); cout<<"NAMA :";
cin>>rbudidarma[n].nama;
gotoxy(35,9); cout<<"Jenjang [D3MI, D3KA, S1TI] :";
gets(rbudidarma[n].jenjang);
gotoxy(35,10); cout<<"Jurusan [Teknik Informatika, Manajemen Informatika] :";
gets(rbudidarma[n].jurusan);
gotoxy(35,11); cout<<"Tahun :";
cin>>rbudidarma[n].tahun;
coba=fopen("c:\\budidarma.Dat","wb");
for (i=0; i<n; ++i)
{
fwrite(&rbudidarma[i], sizeof(rbudidarma[i]),1,coba);
}
fclose(coba);
}
void output_ddosen(){
FILE *coba;
float atof();
clrscr();
coba = fopen("c:\\budidarma.Dat","rb");
if (coba==NULL)
{
gotoxy(20,10); cout<<" File Data.Dat belum ada ";
gotoxy(20,12); cout<<" Tekan Sembarang Tombol ";
getch();
return;
}
gotoxy(5,1); cout<<" Informasi Data Dosen ";
gotoxy(5,2); cout<<" ---------------------------------------------------------------------- ";
gotoxy(5,3); cout<<"No Kode Nama Pendidikan Keahlian";
gotoxy(5,4); cout<<" ---------------------------------------------------------------------- ";
while( (fread(&rbudidarma[n], sizeof(rbudidarma[n]),1,coba))==1)
{
++i;
gotoxy (6,4+i); cout<< i;
gotoxy (10,4+i); cout<<kode;
gotoxy (16,4+i);cout<<nama;
gotoxy (33,4+i);cout<<pend;
gotoxy (43,4+i);cout<<ahli;
}
gotoxy (5,5+i); cout<< "________________________________________" ;
getch();
fclose(coba);
}
void output_dmhsw(){
FILE *coba;
float atof();
clrscr();
coba = fopen("c:\\budidarma.Dat","rb");
if (coba==NULL)
{
gotoxy(20,10); cout<<" File BUDIDARMA.Dat belum ada ";
gotoxy(20,12); cout<<" Tekan Sembarang Tombol ";
getch();
return;
}
gotoxy(5,1); cout<<" Informasi Data Mahasiswa ";
gotoxy(5,2); cout<<" ---------------------------------------------------------------------- ";
gotoxy(5,3); cout<<"No NPM NAMA JENJANG JURUSAN";
gotoxy(5,4); cout<<" ---------------------------------------------------------------------- ";
while( (fread(&rbudidarma[n], sizeof(rbudidarma[n]),1,coba))==1);
{
++i;
gotoxy (6,4+i); cout<< i;
gotoxy (10,4+i); cout<<npm;
gotoxy(16,4+i);cout<<nama;
gotoxy(33,4+i);cout<<jenjang;
gotoxy(43,4+i);cout<<jurusan;
}
gotoxy (5,5+i); cout<< "________________________________________" ;
getch();
fclose(coba);
}
}
NAMA : E S T E R
NPM : 1002247
Kelas : MI.P-1003
Tidak ada komentar:
Posting Komentar