using System;
namespace ConsoleApp11
{
class Program
{
static void Main(string[] args)
{
Person noIncomePerson = new Person()
{
Name = "Billy",
Age = 20,
Income = 20000
};
Person _15IncomePerson = new Person()
{
Name = "Max",
Age = 25,
Income = 100001
};
Person _25IncomePerson = new Person()
{
Name = "Jane",
Age = 25,
Income = 500000
};
noIncomePerson.CalculateTax();
_15IncomePerson.CalculateTax();
_25IncomePerson.CalculateTax();
Console.Write("Press any key...");
Console.ReadKey();
}
}
class Person
{
string name;
int age;
decimal income;
public string Name
{
get { return name; }
set { name = value; }
}
public int Age
{
get { return age; }
set { age = value; }
}
public decimal Income
{
get { return income; }
set { income = value; }
}
public void CalculateTax()
{
if (Income < 100000)
{
Console.WriteLine($"{Name}, No tax applies on you");
}
else if (Income >= 100000 && Income <= 300000)
{
Console.WriteLine($"{Name}, You tax is 15%: {Income * 0.15M}");
}
else
{
Console.WriteLine($"{Name}, You tax is 25%: {Income * 0.25M}");
}
}
}
}
Comments
Leave a comment