Compile-time polymorphism (Method Overloading)

Ranjeet_8
Posted by Ranjeet_8 under C# category on | Points: 40 | Views : 1104

*Compile-time polymorphism (Method Overloading)
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter your Taxable sum...");
double TaxAmt = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter your Tax rate...");
string text = Console.ReadLine();
double TaxRate = 0;
if (text != "")
{
TaxRate = Convert.ToDouble(text);
}
//instanciating the class
Program Prog = new Program();
if (TaxRate > 0)
{
Console.WriteLine("Your Tax amount is : {0}", Prog.Tax(TaxAmt, TaxRate));
}
else
{
Console.WriteLine("Your Tax amount is : {0}", Prog.Tax(TaxAmt));
}
System.Console.ReadLine();
}

private double Tax(double TaxableAmt, double TaxRate)
{
return (TaxableAmt * TaxRate) / 100;
}

private double Tax(double TaxableAmt)
{
double FixRate = 8.33;
return (TaxableAmt * FixRate) / 100;
}
}

Comments or Responses

Login to post response