welcome tinhocK1 website

Saturday, 20/04/2024, 3:09 PM

Chào Guest

Login form

Đăng nhập:
mật khẩu:

Ẩn

Tán Gẫu

500

Bạn thấy web tinhoc K1 thế nào?

Rate my site
Total of answers: 108
[ New messages · Members · Forum rules · Search · RSS ]
  • Page 1 of 1
  • 1
Forum » download » tài liệu chuyên ngành » tinh tien thue bao
tinh tien thue bao
quocdat11 Date: Thursday, 06/11/2008, 8:40 AM | Message # 1
Nhóm: Removed





#include iostream.h
#include conio.h
#include stdio.h
#include string.h
class thuebao
{char sodt[15];
char hoten[50];
char *diachi;
int sophut;

public:
thuebao();
thuebao(char*,char*,char*,int=0);
thuebao(const thuebao&);

void nhap();
void xuat();
thuebao&operator=(const thuebao&);
friend ostream&operator<<(ostream&,const thuebao&);
friend istream&operator>>(istream&,thuebao&);

float tinhcuoc();
float cuocVAT();

char*laysodt()
{return sodt;}
char*layhoten()
{return hoten;}
char*laydiachi()
{return diachi;}
int laysophut()
{return sophut;}
};
thuebao::thuebao()
{strcpy(sodt," ");
strcpy(hoten," ");
diachi=(char*)NULL;
sophut=0;
}
thuebao::thuebao(char*dt,char*ht,char*dc,int sp)
{strcpy(sodt,dt);
strcpy(hoten,ht);
diachi=strdup(dc);
sophut=sp;
}
thuebao::thuebao(const thuebao&t)
{strcpy(sodt,t.sodt);
strcpy(hoten,t.hoten);
diachi=strdup(t.diachi);
sophut=t.sophut;
}
void thuebao::nhap()
{cin>>*this;}
void thuebao::xuat()
{cout<<*this;}
thuebao&thuebao::operator=(const thuebao&t)
{strcpy(sodt,t.sodt);
strcpy(hoten,t.hoten);
if(diachi!=NULL)
delete[]diachi;
diachi=strdup(t.diachi);
sophut=t.sophut;
return*this;
}
ostream&operator<<(ostream&out,const thuebao&tb)
{out<<"thue bao:"< out<<"_HT:"< out<<"_DC:"< out<<"_DT:"< return out;
}
istream &operator>>(istream &in,thuebao &tb)
{char temp[200];
cout<<"So dien thoai:";
in>>tb.sodt;
cout<<"Ho ten:";
gets(tb.hoten);
cout<<"Dia chi:";
gets(temp);

if(tb.diachi !=NULL)
delete []tb.diachi;
tb.diachi=strdup(temp);
cout<<"So phut:";
in>>tb.sophut;
return in;
}
float thuebao::tinhcuoc()
{float kq;
if(sophut<=200)
kq=sophut*120.0;
else if(sophut<=1000)
kq=200*120.0+(sophut-200)*80.0;
else
kq=200*120.0+800*80.0+(sophut-1000)*40.0;
return kq+27000.0;
}
float thuebao::cuocVAT()
{return (tinhcuoc()+tinhcuoc()*0.1);
}
void main()
{thuebao*ds;
int n;
clrscr();
cout<<"Nhap so thue bao:";
cin>>n;
ds=new thuebao[n];
for(int i=0;i {cout<<"Nhap thong tin thue bao thu:"< cin>>ds[i];
}
float tongcuoc=0.0;
for(i=0;i {cout< cout<<"--------------------------"< tongcuoc+=ds[i].tinhcuoc();
}
cout<<"Tong cuoc thu duoc:"< getch();
clrscr();
char ht[50];
cout<<"Nhap ho ten thue bao can tim:";
gets(ht);
cout<<"Ket qua tim kiem:"< for(i=0;i {if(strcmp(ht,ds[i].layhoten())==0)
cout< }
char dt[15];
cout<<"Nhap so dien thoai cua thue bao can tim:";
gets(dt);
cout<<"Ket qua tim kiem:"< for(i=0;i {if(strcmp(dt,ds[i].laysodt())==0)
cout< }
getch();
clrscr();
for(i=0;i {for(int j=i+1;j {if(strcmp(ds[i].layhoten(),ds[j].layhoten())>0)
{thuebao t=ds[i];
ds[i]=ds[j];
ds[j]=t;
}
}
}
cout<<"Danh sach thue bao sau khi sap xep:"< for(i=0;i {cout< cout<<"----------------------------"< }
delete[]ds;
}

 
Forum » download » tài liệu chuyên ngành » tinh tien thue bao
  • Page 1 of 1
  • 1
Search: