Luv Moderators Angle
Tổng số bài gửi : 34 Points : 78 Reputation : 100 Join date : 27/11/2009 Age : 34 Đến từ : Quận 4
| Tiêu đề: ----[L]--- Bài tập C++ Thu Mar 25, 2010 9:28 pm | |
| - Code:
-
#include "stdafx.h" #include <iostream> #include <stdio.h> #include <conio.h> #include <string.h> using namespace std;
class congty { private: char tenct[20],diachi[30]; int sonv,taikhoan; public:
congty(char tct[]="",char dc[]="",int snv=0,int tk=0) { strcpy(tenct,tct); strcpy(diachi,dc); sonv=snv; taikhoan=tk; } void nhapcongty() { cout<<"Nhap vao ten cong ty : "; cin.get(tenct,20); cin.ignore(1); cout<<"Nhap vao dia chi : "; cin.get(diachi,30); cin.ignore(1); cout<<"Nhap vao so nhan vien : "<<endl; cin>>sonv; cout<<"Nhap vao so tai khoan : "<<endl; cin>>taikhoan; cout<<endl; }
void xuatcongty() { cout<<" - Ten cong ty:"<<tenct<<endl; cout<<" - Dia chi:"<<diachi<<endl; cout<<" - So nhan vien:"<<sonv<<endl; cout<<" - So tai khoan:"<<taikhoan<<endl; } int chuyenkhoan() { int mapin=0,tbd=0,tbd1=0,tc=0,tkgoi=0,tknhan=0; float thc=0,thc1=0; cout<<endl;
while (tkgoi<=0) { cout<<"Nhap vao tai khoan goi : "; cin>>tkgoi; if(tkgoi<=0)cout<<"==> Nhap tai khoan goi sai!\n"; } do { cout<<"Nhap vao tai khoan nhan : "; cin>>tknhan; if(tknhan<=0) cout<<"==> Nhap tai khoan nhan sai!\n"; } while (tknhan<=0);
do { cout<<"Nhap vao ma pin : "; cin>>mapin; if(mapin<0||mapin>9)cout<<"==> Nhap ma pin sai!\n"; } while (mapin<0||mapin>9);
cout<<endl; nhaptbd: cout<<"Nhap vao tien ban dau : "; cin>>tbd; if(tbd<=0) { cout<<"==> Nhap tien ban dau sai !\n "; goto nhaptbd; } cout<<endl; while (tc<=0||tc>tbd) { cout<<"nhap vao tien chuyen : "; cin>>tc; if(tc<=0||tc>tbd) cout<<"==> nhap tien chuyen sai!\n"; } cout<<endl; while (tbd1<=0) { cout<<"nhap vao tien ban dau tk nhan : "; cin>>tbd1; if(tbd1<=0) cout<<"==> Nhap tien ban dau tk nhan sai!\n"; } cout<<endl; if(tkgoi!=tknhan) { cout<<"chuyen khoan"; thc=float(tbd-tc); thc1=float(tbd1+tc); } else cout<<"==> Khong chuyen khoan duoc!\n"; cout<<"So tien hien co trong tai khoan goi la : "<<thc<<endl; cout<<"So tien hien co trong tai khoan nhan la : "<<thc1<<endl; cout<<endl; return 0; }
};
int main(int argc, char* argv[]) { congty ct; ct.nhapcongty(); ct.xuatcongty(); ct.chuyenkhoan(); ct.xuatcongty(); printf("\n \t Helleo World!\n\n"); system("PAUSE"); return 0; }
| |
|