Answer to Question #193465 in C++ for Mani

Question #193465

Develop a C++ program for the loan schemes of gold loan and car loan using pure virtual functions. The bank detail consists of data members such as bank name and branch name. The savings account consists of data members such as grams and price. The current account consists of data members such as salary and loan_limit. The member functions are getdetails() and display().


1
Expert's answer
2021-05-16T00:30:31-0400
#include <iostream>
#include <string>
using namespace std;


class Bank
{
public:
	virtual void getdetails() = 0;
	virtual void display() = 0;


protected:
	string  bank_name;
	string branch_name;


};


class Savings: public Bank
{
public:
	Savings() {};
	Savings(string b_n, string br_n, double gr, double pr) 
	{
		getdetails(b_n, br_n, gr, pr);
	}
	void getdetails() { };
	void  getdetails(string b_n, string br_n, double gr, double pr)
	{
		bank_name = b_n;
		branch_name = br_n;
		grams = gr;
		price = pr;
	}
	void display() 
	{
		cout << "Bank name: " << bank_name << endl;
		cout<<"Branch name: "<<branch_name << endl;
		cout<<"Grams: "<<grams << endl;
		cout<<"Price: "<<price << endl;
	}
private:
	double grams{0};
	double price{0};
};
class Current : public Bank
{
public:
	Current() {};
	Current(string b_n, string br_n, double sl, double lm)
	{
		getdetails(b_n, br_n, sl, lm);
	}
	void getdetails() { };
	void getdetails(string b_n, string br_n, double sl, double lm)
	{
		bank_name = b_n;
		branch_name = br_n;
		salary = sl;
		loan_limit= lm;
	}
	void display()
	{
		cout << "Bank name: " << bank_name << endl;
		cout << "Branch name: " << branch_name << endl;
		cout << "Salary: " << salary << endl;
		cout << "Price: " << loan_limit<< endl;
	}


private:
	double salary{ 0 };
	double loan_limit{ 0 };
};


int main()
{
   // test work 
	Savings test_1("Bank_1", "main",12,2300);
	Current test_2;
	test_1.display();
	test_2.getdetails("Bank_2", "main", 5300, 20000);
	test_2.display();
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog