1. Trang chủ
  2. » Tài Chính - Ngân Hàng

cai dat cac lop trong C

3 5 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

[r]

(1)

#include <iostream.h> #include "stdio.h" #include <conio.h> class Date{

int ngay,thang,nam; friend class HD; };

class KHACH{

char mk[10],tk[30],phone[15]; public :

void nhap(); void xuat(); };

class HANG{ char mh[10],th[40]; int solg;

float dongia; public : void nhap(); void xuat(); friend class HD; };

class HD{ int k,sohd; Date ngaylap; KHACH y; HANG H[40]; float tongtien; public : void nhap(); void xuat(); };

void KHACH::nhap()

{ cout<<"nhap ma khach : "; fflush(stdin); gets(mk); cout<<"nhap ten khach : "; fflush(stdin); gets(tk);

cout<<"nhap so phone khach : "; fflush(stdin); gets(phone); }

void KHACH::xuat()

{ cout<<"\tma khach : " <<mk<<endl; cout<<"\tten khach : " <<tk<<endl;

cout<<"\tphone khach : " <<phone<<endl; }

void HANG::nhap()

(2)

cout<<"nhap so luong : ";cin>>solg; }

void HANG::xuat()

{ cout<<"\tma hang : " <<mh<<endl; cout<<"\tten hang : " <<th<<endl; cout<<"\tdon gia : " <<dongia<<endl; cout<<"\tso luong : " <<solg<<endl; }

void HD::nhap()

{ cout<<"nhap so hoa don : ";cin>>sohd; cout<<"ngay lap hoa don : "<<endl;

cin>>ngaylap.ngay>>ngaylap.thang>>ngaylap.nam; cout<<"nhap thong tin khach hang : "<<endl;

y.nhap();

cout<<"so hang hoa hoa don : "; cin>>k; cout<<"nhap danh sach hang hoa : ";

for(int i=0;i<k;i++)

{ cout<<"\tnhap hang thu "<<(i+1)<<" : "<<endl; H[i].nhap();

}

float tg=0;

for(int j=0;j<k;j++)

tg=tg+H[j].dongia * H[j].solg; tongtien=tg;

}

void HD::xuat()

{ cout<<"so hoa don : " <<sohd<<endl; cout<<"ngay : "

<<ngaylap.ngay<<"/"<<ngaylap.thang<<"/"<<ngaylap.nam<<endl; cout<<"khach : "<<endl;

y.xuat();

cout<<"danh sach hang hoa : "<<endl; for(int i=0;i<k;i++)

{ cout<<" Mat Hang thu "<<(i+1)<<" : "<<endl; H[i].xuat();

}

cout<<"tong tien toan : "<<tongtien; }

void main() { HD X;

cout<<"Nhap thong tin : "<<endl; X.nhap();

cout<<"Thong tin hoa don:"<<endl; X.xuat();

(3)

Ngày đăng: 21/05/2021, 12:18

Xem thêm:

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w