avatar
Eb Bill

Guest 119 9th Dec, 2019

CSHARP 2.72 KB
                                           
                         using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication11
{
    class ElectricityBill
	{

            public int unit=0;
			public string Name;
			public string Customerid;
			public double TotalAmount;


            public ElectricityBill(string Name, string Customerid,int unit)
            {
                this.Name = Name;
                this.Customerid = Customerid;
                this.unit = unit;
            }

			public void amountcalculation()
            {

                if (unit < 200)
                {
                    TotalAmount = unit * 1.20;
                    TotalAmount = TotalAmount + (TotalAmount * 0.15);
                    Console.WriteLine(TotalAmount);
                }
                else if (unit < 400)
                {
                    int a = unit - 199;
                    TotalAmount = (a * 1.50) + (199 * 1.20);
                    TotalAmount = TotalAmount + (TotalAmount * 0.15);
                    Console.WriteLine(TotalAmount);
                }
                else if (unit < 600)
                {
                    int b = unit - 400;
                    TotalAmount = (b * 1.80) + (201 * 1.50) + (199 * 1.20);
                    TotalAmount = TotalAmount + (TotalAmount * 0.15);
                    Console.WriteLine(TotalAmount);
                }
                else if (unit > 600)
                {
                    int c = unit - 600;
                    TotalAmount = (c * 2) + (200 * 1.80) + (201 * 1.50) + (199 * 1.20);
                    TotalAmount = TotalAmount + (TotalAmount * 0.15);
                    Console.WriteLine(TotalAmount);
                }
                else
                {
                    Console.WriteLine("The Minimum Amount is 100");
                }

            }

    }
    class mp
    {
        public static void Main()
        {
            try
            {
                Console.WriteLine("Enter The Name");
                string X = Console.ReadLine();
                Console.WriteLine("enter the Customerid");
                string Y =Console.ReadLine();
                Console.WriteLine("enter the unit consumed");
                int Z = Int32.Parse(Console.ReadLine());
                ElectricityBill obj = new ElectricityBill(X,Y,Z);


                obj.amountcalculation();
                Console.ReadLine();
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }

        }
    }
}
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data