C++ Program for Banking

C++ program for banking.

// WAP for getting details of a Bank Account

#include<iostream.h>

#include<conio.h>

#include<stdlib.h>

 int w=101;

 int k;

class bank

{

char name[30];

int accno,amt,bal;

int s;

public:

void getdata();

void deposit();

void withdraw();

void putdata();

};

void bank::getdata()

{

cout<<”nEnter ur name:”;

cin>>name;

cout<<”n Enter ur account number:”;

cin>>accno;

}

void bank::deposit()

{

bal=0;

cout<<”Enter the acc number:”;

cin>>accno;

if(accno==w)

cout<<”n how much  amount u want to deposit:”;

else

cout<<”n Enter the correct account number”;

cin>>amt;

bal=bal+amt;

cout<<”n Balance:”<<bal;

k++;

}

void bank::withdraw()

{

cout<<”n Enter the account number:”;

cin>>accno;

if(accno==w)

cout<<”n How much amount u want to withdraw”;

else

cout<<”n Enter the correct account number”;

cin>>s;

if(bal<=s)

cout<<”n There is no sufficient amount in ur account”;

else

bal=bal-s;

cout<<”n balance:”<<bal;

}

void bank::putdata()

{

cout<<”n Enter the acc num:”;

cin>>accno;

if(accno==w)

cout<<”n Name:”<<name<<”n Balance:”<<bal;

else

cout<<”n Enter the correct account number:”;

}

void main()

{

bank b;

clrscr();

cout<<”**********************************************n”;

cout<<”**********************************************n”;

cout<<”ttt1 Deposit Initial Valuesn”;

cout<<”ttt2 Deposit Ammountn”;

cout<<”ttt3 Withdrawn”;

cout<<”ttt4 Put Datan”;

cout<<”ttt5 exitn”;

cout<<”**********************************************n”;

cout<<”**********************************************n”;

int k;

do

{

cout<<”Enter your choice”;

cin>>k;

do

{

switch(k)

{

case 1:

b.getdata();

break;

case 2:

b.deposit();

break;

case 3:

b.withdraw();

break;

case 4:

b.putdata();

break;

case 5:

exit(0);

break;

default:

cout<<”Wrong choice”;

break;

}

}while(k!=5);

}

Output:-

*********************************************************

*********************************************************

Deposit Initial Values

Deposit Ammount

Withdraw

Put Data

exit

*********************************************************

*********************************************************

Enter your choice 1

Enter ur name: ABC

Enter ur account number:101

Enter your choice  2

Enter the acc number:101

How much  amount u want to deposit:5000

Balance:5000

Enter your choice  3

Enter the acc number:101

How much amount u want to withdraw 500

Balance:4500

Enter your choice  4

Enter the acc number:101

Name: ABC

Balance:4500

Enter your choice  5

comments powered by Disqus
Loading