have code, need comments. //header #include <string> using namespace std; class
ID: 663296 • Letter: H
Question
have code, need comments.
//header
#include <string>
using namespace std;
class bankaccount
{
private:
string name;
int accno;
string acctype;
double balance;
double interest;
public:
bankaccount()
{
name = " ";
accno = 0;
acctype = " ";
balance = 0.0;
interest = 0.0;
}
void getdetails()
{
cout << "Enter the customer name:";
cin >> name;
cout << "Enter the customer Account number:";
cin >> accno;
cout << "Enter the customer Account type:";
cin >> acctype;
cout << "Enter the customer balance:";
cin >> balance;
}
double getbalance()
{
return balance;
}
void deposite(double amt)
{
balance = balance + amt;
}
void withdraw(double amt)
{
balance = balance - amt;
}
void addinterest(double rate)
{
double balamt = (balance)*(rate/100);
deposite (balamt);
}
void printaccdetails()
{
cout << "------------------------------------------" << endl;
cout << "Customer name: " << name << endl;
cout << "Account no.: " << accno << endl;
cout << "Account type: " << acctype << endl;
cout << "Balance (with interest): " << getbalance() << endl;
cout << "------------------------------------------" << endl;
}
};
//main
#include <iostream>
#include "bank.h"
using namespace std;
int main()
{
bankaccount b [10];
for (int i = 0; i < 10; i++)
{
b[i].getdetails();
}
for (int i = 0; i < 10; i++)
{
b[i].addinterest(10);
b[i].printaccdetails();
}
system("pause");
}
Explanation / Answer
Correct one.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.