Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Define a class to represent a bank account. Include the
following
members:
Data Members:
Name of the Depositor
Account Number
Type of Account
Balance amount in the account

Member Functions:
To assign the initial values.
To deposit an account.
To withdraw an amount after checking the balance.

Write a C++ main program to display account number,
name and
balance.

Answer Posted / opender shekhawat

include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>

class Bank
{
private:
int acc_id;
char name[20];
float balance;
public:
Bank();
Bank(int,char[20],float);
Bank(Bank&);
~Bank();
void read();
void deposit(float);
void withdraw(float);
void show();
int getid();
};

Bank::Bank()
{
acc_id = 0;
strcpy(name,'\0');
balance = 0.0;
}

Bank::~Bank()
{
cout<<"DESTRUCTOR!\n";
getch();
}

Bank::Bank(int id,char nm[],float bal)
{
acc_id = id;
strcpy(name,nm);
balance = bal;
}

Bank::Bank(Bank &b)
{
acc_id = b.acc_id;
strcpy(name,b.name);
balance = b.balance;
}

void Bank::read()
{
cout<<"\nenter the account-id : ";
cin>>acc_id;
cout<<"enter name of depositor : ";
fflush(stdin);
cin>>name;
cout<<"enter the balance amount : ";
cin>>balance;
cout<<"---------------------------------\n";
}

void Bank::deposit(float amt)
{
balance = balance + amt;
}

void Bank::withdraw(float amt)
{
balance = balance - amt;
}

void Bank::show()
{
cout<<"\naccount-id = "<<acc_id<<endl;
cout<<"name = "<<name<<endl;
cout<<"balance = "<<balance<<endl;
cout<<"-----------------------------------\n";
}

int Bank::getid()
{
return(acc_id);
}

int search(Bank *b,int tid,int n)
{
int flag, i=0;
while((i<n)&&(!flag))
{
int x;
x = b[i].getid();
if(x==tid)
flag = 1;
else
i++;
}
if(!flag)
return(-1);
else
return(i);
}

void main()
{
clrscr();
Bank cust[10];
int n;
cout<<"enter no.of customers : ";
cin>>n;
for(int i=0;i<n;i++)
cust[i].read();
cout<<"enter the account-id on which u want transactions : ";
fflush(stdin);
int tid;
cin>>tid;
int index=0;
index = search(cust,tid,n);
if (index==-1)
{
cout<<"account-id does not exist!\n";
cout<<"PROGRAM TERMINATION\n";
}
else
{
cout<<"what transaction do u want?\n";
cout<<" 1. DEPOSIT\n 2. WITHDRAW\n";
cout<<"enter ur choice : ";
int ch;
do
{
cin>>ch;
cout<<"ur present balance is :\n";
cust[index].show();
switch(ch)
{
case 1:
float amt;
cout<<"enter the amount u want to deposit : ";
cin>>amt;
cust[index].deposit(amt);
cout<<"ur new balance is :\n";
cust[index].show();
break;
case 2:
cout<<"enter the amount u want to withdraw : ";
cin>>amt;
cust[index].withdraw(amt);
cout<<"ur new balance is :\n";
cust[index].show();
break;
default:
cout<<"PROGRAM TERMINATION\n";
//exit(1);
}
cout<<"enter ur choice again : \n";
}
while((ch==1)||(ch==2));
}
getch();

}

Is This Answer Correct ?    15 Yes 18 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the point of oop?

1160


What is use of overloading?

1118


write string class as your own class in java without using any built-in function

2484


Whats oop mean?

1021


What is encapsulation in ict?

1037


What is polymorphism and why is it important?

1026


Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.

1229


What is the advantage of oop over procedural language?

1065


What is encapsulation in simple terms?

1015


Will I be able to get a picture in D drive to the c++ program? If so, help me out?

2183


Why do pointers exist?

1077


What is the real time example of inheritance?

1131


Which type does string inherit from?

1092


What is encapsulation and abstraction? How are they implemented in C++?

1118


How oops is better than procedural?

1080