Answer to Question #253434 in C# for Dani

Question #253434
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-10-19T15:19:46-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);
        }
        /// <summary>
        /// the concept of overloading
        /// </summary>
        /// <param name="nameZakatDonor"></param>
        /// <param name="bank_Balance"></param>
        /// <param name="zakat_amount"></param>
        public void display(string nameZakatDonor, double bank_Balance, double zakat_amount)
        {
            Console.WriteLine("Zakat donor name: {0}", nameZakatDonor);
            Console.WriteLine("Bank Balance: {0}", bank_Balance);
            Console.WriteLine("Zakat amount: {0}", zakat_amount);
        }


        /// <summary>
        /// copy constructor
        /// </summary>
        public ZakatCalculator(ZakatCalculator otherZakatCalculator)
        {
            this.nameZakatDonor = otherZakatCalculator.nameZakatDonor;
            this.bank_Balance = otherZakatCalculator.bank_Balance;
            this.zakat_amount = otherZakatCalculator.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 zk = new App.ZakatCalculator("ZakatCalculator", 100000);
            zk.Cal_zakat();
            zk.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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS