#include <iostream>
#include <conio>
#include <stdlib>
#include <fstream>
#include <stdio>
struct pasien
{
char no[5];
char nama[30];
char tgl[10];
int umur;
char kode[5];
}
psn1;
void main ()
{
ofstream psnfile ( "pasien.dat",ios::app);
if(!psnfile)
{
cerr<<"file could not be opened "<<endl;
exit(1);
}
char jwb='y';
cout<<"input data pasien"<<endl;
while(jwb=='y')
{
cout<<endl;
cout<<"NO RM =";gets(psn1.no);
cout<<"NAMA =";gets(psn1.nama);
cout<<"TANGGAL BEROBAT =";gets(psn1.tgl);
cout<<"UMUR=";cin>>psn1.umur;
cout<<"KODE PENYAKIT =";gets(psn1.kode);
psnfile.write((char*)& psn1,sizeof(psn1));
cout<<"ada data lain?[y/t]=";cin>>jwb;
}
psnfile.close();
}
#include <iostream.h>
#include <conio.h>
#include <fstream.h>
#include <stdlib.h>
#include <stdio.h>
#include <iomanip.h>
void info ();
struct pasien
{
char no[5];
char nama[30];
char tgl[10];
int umur;
char kode[5];
}psn1;
main ()
{
ifstream psnfile("pasien.dat",ios::in);
if(psnfile)
{
}
int ts=0;
int total=0;
int biaya;
char jp[7];
clrscr ();
cout<<"KLINIK BUNDA"<<endl;;
cout<<"---------------------"<<endl;
cout<<"---------------------"<<endl;
cout<<endl;
cout<<"--------------------------------------------------------------------------------";
cout<< setiosflags(ios::left)<<setw(5)<<"no"<<setw(10)<<"no rm"<<setw(14)<<"nama"
<<setw(11)<<"tgl"<<setw(8)<<"umur"<<setw(10)<<"kode"<<setw(10)<<"jenis"<<setw(20)
<<"biaya"<<endl;
cout<<"--------------------------------------------------------------------------------"<<endl;
psnfile.read((char*) & psn1,sizeof(psn1));
while(!psnfile.eof())
{
info();
psnfile.read((char*) & psn1,sizeof(psn1));
}
cout<<"--------------------------------------------------------------------------------";
if(strcmp (psn1.kode,"01")==0){
strcpy(jp,"ringan");
biaya=50000;
}
else if (strcmp(psn1.kode,"02")==0){
strcpy(jp,"sedang");
biaya=100000;
}
else if (strcmp(psn1.kode,"03")==0){
strcpy(jp,"parah");
biaya=200000;
ts=ts+biaya;
}
total=total+biaya+ts;
cout<<"total biaya seluruhnya="<<total<<endl;
cout<<"total biaya penyakit parah="<<ts<<endl;
psnfile.close();
getch();
}
int no=0;
char jp[7];
int biaya;
int total=0;
int ts=0;
void info()
{
no ++;
if(strcmp (psn1.kode,"01")==0){
strcpy(jp,"ringan");
biaya=50000;
}
else if (strcmp(psn1.kode,"02")==0){
strcpy(jp,"sedang");
biaya=100000;
}
else if (strcmp(psn1.kode,"03")==0){
strcpy(jp,"parah");
biaya=200000;
ts=ts+biaya;
}
total=total+biaya+ts;
cout<< setiosflags(ios::left)<<setw(5)<<no<<setw(10)<<psn1.no<<setw(10)
<<psn1.nama<<setw(15)<<psn1.tgl<<setw(10)<<psn1.umur<<setw(9)
<<psn1.kode<<setw(5)<<setprecision(8)<<jp<<" "<<setw(7)<<biaya<<endl;
}
Subscribe to:
Post Comments (Atom)
CONTOH CODING LINKED LIST MENGGUNAKAN BORLAND C++
CONTOH CODING LINKED LIST MENGGUNAKAN BORLAND C++ #include<stdlib.h> #include<conio.h> #include<iostream.h> struc...
-
#include <iostream.h> #include <conio.h> #include <fstream.h> #include <stdio.h> #include <stdlib.h> struct pa...
-
#include <iostream.h> #include <conio.h> #include <fstream.h> #include <stdio.h> #include <iomanip.h> #include...
-
#include <iostream.h> #include <iomanip.h> #include <stdio.h> #include <conio.h> void coba(); struct rumahsakit { ...
No comments:
Post a Comment