Answer to Question #252944 in C# for An Islamic bank

Question #252944

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


1
Expert's answer
2021-10-18T06:44:55-0400
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();
        }


    }
}

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

Waseem
18.10.21, 13:53

Dear thanks a lot but also send me the screenshots after running program

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS