PLEASE C++ ONLY Define the class bankAccount to implement the basic properties o
ID: 3856981 • Letter: P
Question
PLEASE C++ ONLY
Define the class bankAccount to implement the basic properties of a
bank account. An object of this class should store the following data:
Account holder’s name (string), account number (int), account type
(string, checking/saving), balance (double), and interest rate (double).
(Store interest rate as a decimal number.) Add appropriate member functions
to manipulate an object. Use a static member in the class to
automatically assign account numbers. Also declare an array of 10 components
of type bankAccount to process up to 10 customers and write a
program to illustrate how to use your class.
Explanation / Answer
#include<iostream>
#include<string>
using namespace std;
class bankAccount
{
public:
string name[10],typ[10]; //variable declaration
float bal[10],rate[10];
long int acc[10];
int i;
void input() //input function to accept the details
{
for(i=0;i<10;i++)
{
cout<<"Enter the account holder name ";
cin>>name[i];
cout<<"Enter the account number ";
cin>>acc[i];
cout<<"Enter the type of the account ";
cin>>typ[i];
cout<<"Enter the balance ";
cin>>bal[i];
cout<<"Enter the interest rate ";
cin>>rate[i];
}
}
void display() //display function to show the details
{
cout<<"Name"<<" "<<"Account_No"<<" "<<" Account_Typ"<<" "<<"Balance"<<" "<<" Rate"<<endl;
for(i=0;i<2;i++)
{
cout<<name[i]<<" "<<acc[i]<<" "<<typ[i]<<" "<<bal[i]<<" "<<rate[i]<<endl;
}
}
};
int main() //main fucntion
{
bankAccount obj; //object of the class
obj.input(); //calling the function
obj.display();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.