diff --git a/second/Payment.cs b/second/Payment.cs new file mode 100644 index 0000000..15e1694 --- /dev/null +++ b/second/Payment.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace second +{ + public class Payment + { + public string FullName { get; set; } + + public double Salary { get; set; } + + public int HireYear { get; set; } + + public double BonusPercent { get; set; } + + public double IncomeTaxPercent { get; set; } = 13.0; + + public int DaysWorked { get; set; } + + public int WorkDaysInMonth { get; set; } + + public double Accrued { get; private set; } + + public double Withheld { get; private set; } + + public Payment( + string fullName, + double salary, + int hireYear, + double bonusPercent, + int daysWorked, + int workDaysInMonth //, :( + ) + { + FullName = fullName; + Salary = salary; + HireYear = hireYear; + BonusPercent = bonusPercent; + DaysWorked = daysWorked; + WorkDaysInMonth = workDaysInMonth; + } + + public double CalcAccrued() + { + double basePay = Salary * DaysWorked / WorkDaysInMonth; + double bonus = basePay * (BonusPercent / 100.0); + Accrued = basePay + bonus; + + return Accrued; + } + + public double CalcWithheld() + { + double pension = Accrued * 0.01; // I’m old, you know, like I saw the way dinosaurs died + double incomeTax = Accrued * (IncomeTaxPercent / 100.0); + Withheld = pension + incomeTax; + + return Withheld; + } + + public double CalcNet() + { + return Accrued - Withheld; + } + + public int CalcXP() + { + int currentYear = DateTime.Now.Year; + int xp = currentYear - HireYear; + return xp; + } + + public override string ToString() + { + return $"Name: {FullName}\nSalary: {Salary}\nXP: {CalcXP()} (HireYear is {HireYear})\nBonus: {BonusPercent}%\nIncomeTax: {IncomeTaxPercent}%\nWorkDaysInMonth: {WorkDaysInMonth} {(WorkDaysInMonth > 1 ? "days" : "day")}\nWorked: {DaysWorked}\nTotalAccrued: {CalcAccrued()}\nWithheld: {CalcWithheld()}\nActuallyAccrued: {CalcNet()}"; + } + } +} + diff --git a/second/Program.cs b/second/Program.cs new file mode 100644 index 0000000..cd49d5c --- /dev/null +++ b/second/Program.cs @@ -0,0 +1,20 @@ +namespace second +{ + internal class Program + { + static void Main(string[] args) + { + Payment payment = + new Payment( + "Шумилкин Александр Олегович", + 328000, + 2022, + 5, + 20, + 28 + ); + + Console.WriteLine( payment.ToString() ); + } + } +} diff --git a/second/second.csproj b/second/second.csproj new file mode 100644 index 0000000..fd4bd08 --- /dev/null +++ b/second/second.csproj @@ -0,0 +1,10 @@ + + + + Exe + net9.0 + enable + enable + + + diff --git a/second/second.sln b/second/second.sln new file mode 100644 index 0000000..3daadfb --- /dev/null +++ b/second/second.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36429.23 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "second", "second.csproj", "{A65ADBD8-8CF6-459A-876B-37A293CE1A2C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A65ADBD8-8CF6-459A-876B-37A293CE1A2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A65ADBD8-8CF6-459A-876B-37A293CE1A2C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A65ADBD8-8CF6-459A-876B-37A293CE1A2C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A65ADBD8-8CF6-459A-876B-37A293CE1A2C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {73786AFD-602C-4DBA-AAC9-25A62DADDCC2} + EndGlobalSection +EndGlobal