Member Avatar for HASHMI007
// bakers.cpp : Defines the entry point for the console application.
//



/* HEADER USED IN THIS PROJECT*/
#include "stdafx.h"
#include<iostream>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<stdio.h>
#include<process.h>
#include<fstream>
#include<ctype.h>

using namespace std;

//Classes in this program

class Bank {

private :
long Ac_no;
string f_name , l_name ,City;
char Ac_type;
float deposit, withdraw;


public :
void CreatNew_Account();
void Recreat_Account();
void RemoveAccount();
void ModifyAccount();
void Cardit();
void Debit();
void Bal_Inquiry();
void ShowAcc_Detail();
void bal_inquriy();
void Transection_of_Accounts();
long ret_AccNO()
{
return Ac_no;
}
void dep(int x)
{
  deposit+=x;
}

void draw(int x)
{
  deposit-=x;
}
/*void ret_type(){

return Ac_type();
}*/
void report()
{cout<<Ac_no<<"\t"<<f_name<<l_name<<"\t\t"<<Ac_type<<"\t\t"<<deposit<<endl;}

};
Bank b;
fstream fp;
void Bank ::CreatNew_Account(){
	fp.open("Account.dat",ios::in |ios::app);
	
	//b.CreatNew_Account();
	 cout<<"\nEnter The account No.";
	 cin>>Ac_no;
	 cout<<"\nEnter The Name of The account Holder First name :-  ";
	 cin>>f_name;
	 cout<<"\nEnter The Name of The account Holder First name :-  ";
	 cin>>l_name;
	 cout<<"\nEnter Type of The account (C/S) ";
	 cin>>Ac_type;
	 Ac_type=toupper(Ac_type);//for upper case
	 cout<<"\nEnter The Initial amount(>=500 for Saving and >=1000 for current ) :- ";
	 cin>>deposit;
	 fp.write((char*)&b,sizeof(Bank)); 
	 fp.close();
}
void Bank::Recreat_Account(){
	cout<<"\nEnter The Name of The account Holder First name :-  ";
	cin>>f_name;
	cout<<"\nEnter The Name of The account Holder First name :-  ";
	cin>>l_name;
    cout<<"\nEnter Type of The account (C/S) ";
	cin>>Ac_type;
	Ac_type=toupper(Ac_type);//for upper case
	cout<<"\nEnter The Initial amount(>=500 for Saving and >=1000 for current ) :- ";
	cin>>deposit;

}
void Bank::ShowAcc_Detail(){
	 cout<<"\n\n\n   WLx Account holder Deatail   ";
	 cout<<"\nAccount No. : "<<Ac_no;
	 cout<<"\nAccount Holder Name : "<<f_name<<" "<<l_name;
	 cout<<"\nType of Account : "<<Ac_type;
	 cout<<"\nBalance amount : "<<deposit;

}
void Bank::bal_inquriy(){
	cout<<"\n............Wlx Balance Inqury Menu........."<<endl;
	int Acno;
	int flag=0;
	cout<<"Enter the Account no :-  ";
	cin>>Acno;
	
    
	 fp.open("Account.dat",ios::in|ios::out);
    while(fp.read((char*)&b,sizeof(Bank)))
	{
		if(Acno==b.ret_AccNO()){
	    cout<<"\nBALANCE DETAILS\n";
	 
		b.ShowAcc_Detail();
		flag=1;
		}
		
	}
	fp.close();
	getch();
if(flag==0){
 cout<<"\n\nAccount number does not exist plz contect to ur system Administrator";
}
}
	

void Bank::ModifyAccount(){
	cout<<"\n\n\n   WLx Modify_Account    ";
	int Acno;
	cout<<"\n\nEnter your Accont no:-  ";
	cin>>Acno;
	int found=0;
	fp.open("Account.dat",ios::in|ios::out);
	while((fp.read((char*)&b,sizeof(Bank)) && found==0))

	if(Acno==b.ret_AccNO()){

	b.ShowAcc_Detail();
	
		    cout<<"\n\n\n.........New Detail......."<<endl;
			b.Recreat_Account();
		    int pos=-1*sizeof(b);
		    fp.seekp(pos,ios::cur);
		    fp.write((char*)&b,sizeof(Bank));
		    cout<<"\n\n\t Record Updated";
		    found=1;
			fp.close();	
	//getch();//may be
	
	}
	if (found==0){
	cout<<"No result fount plx contect to system administrator";
	}
	getch();
	system("cls");

}
/*void Bank::Transection_of_Accounts(){

	int Acno;
	int flag=0;
	cout<<"Enter the Account No : - ";
	cin>>Acno;

	fp.open("Account.dat",ios::in|ios::out);
    while(fp.read((char*)&b,sizeof(Bank)))
	{
		if(Acno==b.ret_AccNO()){
	    cout<<"\n* Transection *\n";
	 
		b.ShowAcc_Detail();
	float Trnf_Rs;
	cout<<"Enter the money that you want to Tranfred :-  ";
	cin>>Trnf_Rs;
	        b.deposit  = b.deposit + Trnf_Rs;
	        int pos=-1*sizeof(b);
		    fp.seekp(pos,ios::cur);
		    fp.write((char*)&b,sizeof(Bank));
		    cout<<"\n\n\t Record Updated";
		flag=1;
		}
		
	}
	fp.close();
	getch();
if(flag==0){
 cout<<"\n\nAccount number does not exist plz contect to ur system Administrator";
}
}
*/

int main(){
	int no;
	Bank B;
	cout<<"\nEnter 1 for creatNewAccount "; 
	cout<<"\nEnter 2 for Modify_Account ";
	cout<<"\nEnter 3 for For Balance Iquiry ";
	cout<<"\nEnter 4 for For Modifying Accounts ";
	cout<<"\nEnter 5 for Transection of Money ";
	cout<<"\n\n\n\Presss any key continue...";
	getch();
	
	cout<<"\n\n\n\nEnter your choise ";
    cin>>no;
	
	switch(no){
		
	case 1:
             
			 b.CreatNew_Account();
		     //creatAccount();
			 getch();
			 system("cls");
			 break;
	
	case 2:
		    
				//b.ModifyAccount();
			getch();
			system("cls");
			break;
			
	case 3:
			
				b.bal_inquriy();
			getch();
			system("cls");
			break;
	case 4:
			
		    b.ModifyAccount();
			getch();
			system("cls");
			break;
	case 5:
			
		    b.Transection_of_Accounts();
			getch();
			system("cls");
			break;
				
			
	}
	return 0;
	getch();
}

Any one can tel me the logic of Transaction of Money from one account to Another Account

Recommended Answers

All 8 Replies

Any one can tel me the logic of Transaction of Money from one account to Another Account

Way too vague. What "logic" do you want explained? How banking works? How the code works? If the latter, there are several directions one can go from that. Overall logic and thought process and "flow" of the code, the syntax itself, etc.

By the way, who WROTE this code? If it was you, then YOU should tell US what the logic of the code is and perhaps we can offer opinions on whether your approach is a good one, how to fix something, etc. That's 250 lines. Surely you can point us to where you're stuck.

Then again, maybe you DIDN'T write the code. In that case, why are you POSTING the code? If it ain't yours, you need to be up front about that.

Anyway, regardless, you need to tell us way more than you're telling us. If I wanted to help, here's what I'd have to do...

  1. Compile it and see if it compiles. You haven't told us whether it does.
  2. Run it. See if it runs. See if it gives good answers.
  3. Try to figure out what it's supposed to do. You haven't told us.
  4. Figure out what input to give it and how to test it. You haven't told us.
  5. Figure out whether the program runs perfectly. Fora ll we know, it does and you just want us to tell you from start to finish how it works.

These are all YOUR job. You need to clearly and concisely articulate what you want before you ask for help. I'm not going to waste my time trying to debug a program that for all I know compiles and runs perfectly.

commented: nyc said +0
Member Avatar for HASHMI007

i complete program.it run.bt my question is that i hve function name

Transect ion_of_Accounts()

through this function how check an account and transferee its money to an other Account.for example i hve to account having there Account no 1,and 2.i want transfer money from Account # 01 to Account #02.how u people suggest me ,how can i write this type of easly plx tell me how write such type of code.

thankxx

Member Avatar for HASHMI007

my mind stop at that point ...

Any one can tel me the logic of Transaction of Money from one account to Another Account

u write some code of this fuction

Transect ion_of_Accounts()

A transfer of $400 from Account A to Account B is a $400 withdrawal from Account A and a $400 deposit to Account B, so before you can have a transfer between two accounts, you need to be able to deposit to and withdraw from one account. Make sure you can do both of those things before trying to tackle transfers. Once you have those functions, you can design a transfer function where you withdraw money from one and deposit into the other.

Member Avatar for HASHMI007
//***************************************************************
//                   HEADER FILE USED IN PROJECT
//****************************************************************

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<fstream.h>
#include<ctype.h>

//***************************************************************
//                   CLASS USED IN PROJECT
//****************************************************************

class account
{
 int acno;
 char name[50];
 int deposit, withdraw;
 char type;
 public:
	void create_account()
	{
	 cout<<"\nEnter The account No.";
	 cin>>acno;
	 cout<<"\n\nEnter The Name of The account Holder ";
	 gets(name);
	 cout<<"\nEnter Type of The account (C/S) ";
	 cin>>type;
	 type=toupper(type);
	 cout<<"\nEnter The Initial amount(>=500 for Saving and >=1000 for current )";
	 cin>>deposit;
	 cout<<"\n\n\nAccount Created..";
			}

	void show_account()
	{
	 cout<<"\nAccount No. : "<<acno;
	 cout<<"\nAccount Holder Name : ";
	 puts(name);
	 cout<<"\nType of Account : "<<type;
	 cout<<"\nBalance amount : "<<deposit;
	 }

		  void modify_account()
	{
	 cout<<"\nAccount No. : "<<acno;
	 cout<<"\nModify Account Holder Name : ";
	 gets(name);
	 cout<<"\nModify Type of Account : ";cin>>type;
	 cout<<"\nModify Balance amount : ";cin>>deposit;
	 }

void dep(int x)
{
  deposit+=x;
}

void draw(int x)
{
  deposit-=x;
}

void report()
{cout<<acno<<"\t"<<name<<"\t\t"<<type<<"\t\t"<<deposit<<endl;}

  int  retacno()
  {return acno;}

  float retdeposit()
  {return deposit;}

  char rettype()
  {return type;}

};         //class ends here



//***************************************************************
//    	global declaration for stream object, object
//****************************************************************

 fstream fp;
 account ac;


//***************************************************************
//    	function to write in file
//****************************************************************

void write_account()
	{
	 fp.open("account.dat",ios::out|ios::app);
	 ac.create_account();
	 fp.write((char*)&ac,sizeof(account));
	 fp.close();
	}



//***************************************************************
//    	function to read specific record from file
//****************************************************************


void display_sp(int n)
{
	 clrscr();
	 cout<<"\nBALANCE DETAILS\n";
	 int flag=0;
	 fp.open("account.dat",ios::in);
	 while(fp.read((char*)&ac,sizeof(account)))
	{
	 if(ac.retacno()==n)
		{
		 ac.show_account();
		 flag=1;
		}
	}
	 fp.close();
if(flag==0)
 cout<<"\n\nAccount number does not exist";
	 getch();
}


//***************************************************************
//    	function to modify record of file
//****************************************************************


void modify_account()
{
	 int no,found=0;
	 clrscr();
	 cout<<"\n\n\tTo Modify ";
	 cout<<"\n\n\tEnter The account No. of The account";
	 cin>>no;
	 fp.open("account.dat",ios::in|ios::out);
	 while(fp.read((char*)&ac,sizeof(account)) && found==0)
		{
		 if(ac.retacno()==no)
			{
			 ac.show_account();
			 cout<<"\nEnter The New Details of account"<<endl;
			 ac.modify_account();
			 int pos=-1*sizeof(ac);
			 fp.seekp(pos,ios::cur);
			 fp.write((char*)&ac,sizeof(account));
			 cout<<"\n\n\t Record Updated";
			 found=1;
			}
		  }
	 fp.close();
	 if(found==0)
	 cout<<"\n\n Record Not Found ";
	 getch();
}


//***************************************************************
//    	function to delete record of file
//****************************************************************


void delete_account()
	{
	 int no;
	 clrscr();
	 cout<<"\n\n\n\tDelete Record";
	 cout<<"\n\nEnter The account no. of the customer You Want To Delete";
	 cin>>no;
	 ac.show_account();
	 fp.open("account.dat",ios::in|ios::out);
	 fstream fp2;
	 fp2.open("Temp.dat",ios::out);
	 fp.seekg(0,ios::beg);
	 while(fp.read((char*)&ac,sizeof(account)))
	{
	 if(ac.retacno()!=no)
		{
		 fp2.write((char*)&ac,sizeof(account));
		 }
	 }
	 fp2.close();
	 fp.close();
	 remove("account.dat");
	 rename("Temp.dat","account.dat");
	 cout<<"\n\n\tRecord Deleted ..";
	 getch();
	 }


//***************************************************************
//    	function to display all accounts deposit list
//****************************************************************

	 void display_all()
	 {
	  clrscr();
	  fp.open("account.dat",ios::in);
	  if(!fp)
	  {
		 cout<<"ERROR!!! FILE COULD NOT BE OPEN\n\n\n Go To Admin Menu to create File";
		 getch();
		 return;
	  }

	  cout<<"\n\n\t\tACCOUNT HOLDER LIST\n\n";
	  cout<<"====================================================\n";
	  cout<<"A/c no.\tNAME\t\tType\t\tBalance\n";
	  cout<<"====================================================\n";

		while(fp.read((char*)&ac,sizeof(account)))
	 {
		ac.report();
	}
	  fp.close();
}


//***************************************************************
//    	function to deposit and withdraw amounts
//****************************************************************

void deposit_withdraw(int option)
{
	 int no,found=0,amt;
	 clrscr();
	 cout<<"\n\n\tEnter The account No.";
	 cin>>no;
	 fp.open("account.dat",ios::in|ios::out);
	 while(fp.read((char*)&ac,sizeof(account)) && found==0)
		 {
		 if(ac.retacno()==no)
		{
			 ac.show_account();
			 if(option==1)
				 {
			cout<<"\n\n\tTO DEPOSITE AMOUNT ";
			cout<<"\n\nEnter The amount to be deposited";
			cin>>amt;
			ac.dep(amt);
				 }
			  if(option==2)
				 {
			cout<<"\n\n\tTO WITHDRAW AMOUNT ";
			cout<<"\n\nEnter The amount to be withdraw";
			cin>>amt;
			 int bal=ac.retdeposit()-amt;
			 if((bal<500 && ac.rettype()=='S') || (bal<1000 && ac.rettype()=='C'))
					cout<<"Insufficience balance";
					else
					 ac.draw(amt);
				}
			 int pos=-1*sizeof(ac);
			 fp.seekp(pos,ios::cur);
			 fp.write((char*)&ac,sizeof(account));
			 cout<<"\n\n\t Record Updated";
			 found=1;
			 }
			}
	 fp.close();
	 if(found==0)
	 cout<<"\n\n Record Not Found ";
	 getch();
}





//***************************************************************
//    	INTRODUCTION FUNCTION
//****************************************************************

void intro()
{
 clrscr();
 gotoxy(31,11);
 cout<<"BANKING";
 gotoxy(35,14);
 cout<<"TRANSACTIONS";
 gotoxy(35,17);
 cout<<"SYSTEM";
 cout<<"\n\nMADE BY :SAFWAN HASHMI";
 cout<<"\n\nSCHOOL : bahria";
 getch();

}



//***************************************************************
//    	THE MAIN FUNCTION OF PROGRAM
//****************************************************************


void main()
{
  char ch;
  intro();
  do
	 {
	  clrscr();
	  cout<<"\n\n\n\tMAIN MENU";
	  cout<<"\n\n\t01. NEW ACCOUNT";
	  cout<<"\n\n\t02. DEPOSIT AMOUNT";
	  cout<<"\n\n\t03. WITHDRAW AMOUNT";
	  cout<<"\n\n\t04. BALANCE ENQUIRY";
	  cout<<"\n\n\t05. ALL ACCOUNT HOLDER LIST";
	  cout<<"\n\n\t06. CLOSE AN ACCOUNT";
	  cout<<"\n\n\t07. MODIFY AN ACCOUNT";
	  cout<<"\n\n\t08. EXIT";
	  cout<<"\n\n\tSelect Your Option (1-8) ";
	  ch=getche();
	  switch(ch)
	  {
		case '1': clrscr();
			  write_account();
			  getch();
			break;
		case '2': clrscr();
			  deposit_withdraw(1);
			  break;
		case '3': clrscr();
			  deposit_withdraw(2);
			  getch();
					  break;
		case '4': int num;
					  clrscr();
					  cout<<"\n\n\tEnter The account No. ";
					  cin>>num;
					  display_sp(num);
					  break;
		case '5': clrscr();
			  display_all();
			getch();
			 break;
		case '6': delete_account();
			  break;
		 case '7': clrscr();
					  modify_account();
				getch();
				break;
		  case '8':exit(0);
		  default :cout<<"\a";
	}
	 }while(ch!='8');
}

//***************************************************************
//    			END OF PROJECT
//***************************************************************

this is my work ..bt now i want a of tansfer money...can u explain me way of transferring money

Member Avatar for HASHMI007

i m student. can u point out my weakness...and tell me more about banking system that i hve not added in this prograam...and how can i reduce its length

A transfer of $400 from Account A to Account B is a $400 withdrawal from Account A and a $400 deposit to Account B, so before you can have a transfer between two accounts, you need to be able to deposit to and withdraw from one account. Make sure you can do both of those things before trying to tackle transfers. Once you have those functions, you can design a transfer function where you withdraw money from one and deposit into the other.

first u chk the account from u transfer have a money or no,if hve then u can trfer money to other Account.......

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.