C
chicky
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
class TAccount
{
private:
char AccountNumber[10];
float Balance;
public:
TAccount(char *Number);
void Deposit(float Amount);
void Withdraw(float Amount);
float TellBalance();
};
TAccount::TAccount(char *Number)
{
strcpy(AccountNumber,Number);
Balance=0.0F;
}
void TAccount::Deposit(float Amount)
{
if(Amount<0.0)
cout<<"Deposit:-Amount must be greater than zero!"<<endl;
else
Balance+=Amount;
}
void TAccount::Withdraw(float Amount)
{
if(Amount>Balance)
cout<<"Wrong operation!"<<endl;
else
Balance-=Amount;
}
float TAccount::TellBalance()
{
return Balance;
}
//-------------------------------------------------------
class TCustomer
{
private:
char Name[20];
TAccount *Server;
public:
TCustomer(char *AName,TAccount *TheServer);
void Deposit(float Amount);
void Withdraw(float Amount);
float TellBalance();
};
TCustomer::TCustomer(char *AName,TAccount *TheServer)
{
strcpy(Name,AName);
Server=TheServer;
}
void TCustomer::Deposit(float Amount)
{
Server->Deposit(Amount);
}
void TCustomer::Withdraw(float Amount)
{
Server->Withdraw(Amount);
}
float TCustomer::TellBalance()
{
return Server->TellBalance();
}
//------------------------------------------------------
void main()
{
TAccount *Account=new TAccount("700610062");
TCustomer *You=new TCustomer("You",Account);
while(1)
{
cout<<"*******************************"<<endl;
cout<<"1--Deposit"<<endl;
cout<<"2--Withdraw"<<endl;
cout<<"3--Query balance"<<endl;
cout<<"0--Exit"<<endl;
cout<<"Enter your choice<0-3>:";
int choice;
cin>>choice;
float amount;
switch(choice)
{
case 0:
delete Account;
delete You;
exit(1);
case 1:
cout<<"Enter the amount:";
cin>>amount;
You->Deposit(amount);
break;
case 2:
cout<<"Enter the amount:";
cin>>amount;
You->Withdraw(amount);
break;
case 3:
cout<<"The balance is "<<You->TellBalance()<<endl;
break;
default:
cout<<"unknown choice"<<endl;
}
}
}
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
class TAccount
{
private:
char AccountNumber[10];
float Balance;
public:
TAccount(char *Number);
void Deposit(float Amount);
void Withdraw(float Amount);
float TellBalance();
};
TAccount::TAccount(char *Number)
{
strcpy(AccountNumber,Number);
Balance=0.0F;
}
void TAccount::Deposit(float Amount)
{
if(Amount<0.0)
cout<<"Deposit:-Amount must be greater than zero!"<<endl;
else
Balance+=Amount;
}
void TAccount::Withdraw(float Amount)
{
if(Amount>Balance)
cout<<"Wrong operation!"<<endl;
else
Balance-=Amount;
}
float TAccount::TellBalance()
{
return Balance;
}
//-------------------------------------------------------
class TCustomer:public TAccount
{
private:
char Name[20];
public:
TCustomer(char *AName):TAccount(AName)
{
strcpy(Name,AName);
}
};
//------------------------------------------------------
void main()
{
TAccount *Account=new TAccount("980204");
TCustomer *You=new TCustomer("Daisy");
while(1)
{
cout<<"*******************************"<<endl;
cout<<"1--Deposit"<<endl;
cout<<"2--Withdraw"<<endl;
cout<<"3--Query balance"<<endl;
cout<<"0--Exit"<<endl;
cout<<"Enter your choice<0-3>:";
int choice;
cin>>choice;
float amount;
switch(choice)
{
case 0:
delete Account;
delete You;
exit(1);
case 1:
cout<<"Enter the amount:";
cin>>amount;
You->Deposit(amount);
break;
case 2:
cout<<"Enter the amount:";
cin>>amount;
You->Withdraw(amount);
break;
case 3:
cout<<"The balance is "<<You->TellBalance()<<endl;
break;
default:
cout<<"unknown choice"<<endl;
}
}
}
#include <string.h>
#include <stdlib.h>
class TAccount
{
private:
char AccountNumber[10];
float Balance;
public:
TAccount(char *Number);
void Deposit(float Amount);
void Withdraw(float Amount);
float TellBalance();
};
TAccount::TAccount(char *Number)
{
strcpy(AccountNumber,Number);
Balance=0.0F;
}
void TAccount::Deposit(float Amount)
{
if(Amount<0.0)
cout<<"Deposit:-Amount must be greater than zero!"<<endl;
else
Balance+=Amount;
}
void TAccount::Withdraw(float Amount)
{
if(Amount>Balance)
cout<<"Wrong operation!"<<endl;
else
Balance-=Amount;
}
float TAccount::TellBalance()
{
return Balance;
}
//-------------------------------------------------------
class TCustomer
{
private:
char Name[20];
TAccount *Server;
public:
TCustomer(char *AName,TAccount *TheServer);
void Deposit(float Amount);
void Withdraw(float Amount);
float TellBalance();
};
TCustomer::TCustomer(char *AName,TAccount *TheServer)
{
strcpy(Name,AName);
Server=TheServer;
}
void TCustomer::Deposit(float Amount)
{
Server->Deposit(Amount);
}
void TCustomer::Withdraw(float Amount)
{
Server->Withdraw(Amount);
}
float TCustomer::TellBalance()
{
return Server->TellBalance();
}
//------------------------------------------------------
void main()
{
TAccount *Account=new TAccount("700610062");
TCustomer *You=new TCustomer("You",Account);
while(1)
{
cout<<"*******************************"<<endl;
cout<<"1--Deposit"<<endl;
cout<<"2--Withdraw"<<endl;
cout<<"3--Query balance"<<endl;
cout<<"0--Exit"<<endl;
cout<<"Enter your choice<0-3>:";
int choice;
cin>>choice;
float amount;
switch(choice)
{
case 0:
delete Account;
delete You;
exit(1);
case 1:
cout<<"Enter the amount:";
cin>>amount;
You->Deposit(amount);
break;
case 2:
cout<<"Enter the amount:";
cin>>amount;
You->Withdraw(amount);
break;
case 3:
cout<<"The balance is "<<You->TellBalance()<<endl;
break;
default:
cout<<"unknown choice"<<endl;
}
}
}
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
class TAccount
{
private:
char AccountNumber[10];
float Balance;
public:
TAccount(char *Number);
void Deposit(float Amount);
void Withdraw(float Amount);
float TellBalance();
};
TAccount::TAccount(char *Number)
{
strcpy(AccountNumber,Number);
Balance=0.0F;
}
void TAccount::Deposit(float Amount)
{
if(Amount<0.0)
cout<<"Deposit:-Amount must be greater than zero!"<<endl;
else
Balance+=Amount;
}
void TAccount::Withdraw(float Amount)
{
if(Amount>Balance)
cout<<"Wrong operation!"<<endl;
else
Balance-=Amount;
}
float TAccount::TellBalance()
{
return Balance;
}
//-------------------------------------------------------
class TCustomer:public TAccount
{
private:
char Name[20];
public:
TCustomer(char *AName):TAccount(AName)
{
strcpy(Name,AName);
}
};
//------------------------------------------------------
void main()
{
TAccount *Account=new TAccount("980204");
TCustomer *You=new TCustomer("Daisy");
while(1)
{
cout<<"*******************************"<<endl;
cout<<"1--Deposit"<<endl;
cout<<"2--Withdraw"<<endl;
cout<<"3--Query balance"<<endl;
cout<<"0--Exit"<<endl;
cout<<"Enter your choice<0-3>:";
int choice;
cin>>choice;
float amount;
switch(choice)
{
case 0:
delete Account;
delete You;
exit(1);
case 1:
cout<<"Enter the amount:";
cin>>amount;
You->Deposit(amount);
break;
case 2:
cout<<"Enter the amount:";
cin>>amount;
You->Withdraw(amount);
break;
case 3:
cout<<"The balance is "<<You->TellBalance()<<endl;
break;
default:
cout<<"unknown choice"<<endl;
}
}
}
小鸡无毛飞不高