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
using System;
using System.Collections.Generic;
namespace App
{
class ZakatCalculator
{
private string nameZakatDonor;
private double bank_Balance;
private double zakat_amount;
/// <summary>
/// Constructor to initialize variables with default values which will be called on the time of object instantiation.
/// </summary>
/// <param name="nameZakatDonor"></param>
/// <param name="bank_Balance"></param>
/// <param name="zakat_amount"></param>
public ZakatCalculator(string nameZakatDonor = "", double bank_Balance = 0, double zakat_amount = 0)
{
this.nameZakatDonor = nameZakatDonor;
this.bank_Balance = bank_Balance;
this.zakat_amount = zakat_amount;
}
/// <summary>
/// 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.
/// </summary>
public void Cal_zakat()
{
if (bank_Balance >= 20000)
{
zakat_amount = bank_Balance * 2.5 / 100.0;
}
}
/// <summary>
/// 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
/// </summary>
public void display()
{
Console.WriteLine("Zakat donor name: {0}", nameZakatDonor);
Console.WriteLine("Bank Balance: {0}", bank_Balance);
Console.WriteLine("Zakat amount: {0}", zakat_amount);
}
public string NameZakatDonor
{
get { return nameZakatDonor; }
set { nameZakatDonor = value; }
}
public double Bank_Balance
{
get { return bank_Balance; }
set { bank_Balance = value; }
}
public double Zakat_amount
{
get { return zakat_amount; }
set { zakat_amount = value; }
}
}
class Program
{
static void Main(string[] args)
{
ZakatCalculator ZakatCalculator = new App.ZakatCalculator("Test name", 50000);
ZakatCalculator.Cal_zakat();
ZakatCalculator.display();
Console.ReadLine();
}
}
}
Comments
Dear thanks a lot but also send me the screenshots after running program
Leave a comment