Answer to Question #217901 in C++ for Ahmed Ali

Question #217901

An Islamic bank wants you to develop a Zakat Calculator for them. The calculator shall take the input of the:

1) name of zakat donor,

2) Bank_Balance

3) zakat_amount.

Create constructor to initialize variables with default values which will be called on the time of object instantiation.

There should be a method named “Cal_zakat()” which calculates the zakat of each donor and set in zakat_amount. The program adds up the zakat of each donor hence calculating the total_zakat of the bank. Use a “display()” which displays not only the data of the donor but also the total amount of zakat of the bank. It should keep in mind that the zakat will be calculated only if Bank_Balance is greater than or equal to 20,000. (You should implement the concept of overloading, copy constructor or overriding wherever it is applicable)

Note: Zakat will be calculated by the formula (Bank_Balance *2.5)/100. 


1
Expert's answer
2021-07-17T01:30:21-0400
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
class zakat{
	public:
		string zakat_donor;
		int bank_balance;
		int zakat_amount;
		
		zakat()
		{
			zakat_donor = "";
			bank_balance = 0;
			zakat_amount = 0;
		}
		
		void input()
		{
			string s;
			cout<<"Enter Zakat Donor name : ";
			cin>>s;
			zakat_donor = s;
			cout<<"Enter bank balance : ";
			int n;
			cin>>n;
			bank_balance = n;
		}
		
		int Cal_Zakat()
		{
			if(bank_balance >= 20000)
				zakat_amount = 	bank_balance*2.5/100;
		}
		
		void display()
		{
			cout<<"Zakat donor name : "<<zakat_donor<<endl;
			cout<<"Bank Balance : "<<bank_balance<<endl;
			cout<<"Zakat amount : "<<zakat_amount<<endl;			
		}
		
};


int main()
{
	int n;
	cout<<"Enter number of zakat donors : ";
	cin>>n;
	cout<<endl<<endl;
	zakat z[n];
	for(int i=0; i<n; i++)
	{
		z[i].input();
		cout<<endl;
	}
	
	
	cout<<"Displaying all users"<<endl<<"---------------------------"<<endl;
	for(int i=0; i<n; i++)
	{
		z[i].Cal_Zakat();
		z[i].display();
		cout<<endl;
	}
	
}




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
APPROVED BY CLIENTS