1
0

second ex

This commit is contained in:
2026-01-29 20:09:31 +03:00
parent de89a5bcc7
commit 7224c4f525
4 changed files with 137 additions and 0 deletions

82
second/Payment.cs Normal file
View File

@@ -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; // Im 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()}";
}
}
}

20
second/Program.cs Normal file
View File

@@ -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() );
}
}
}

10
second/second.csproj Normal file
View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

25
second/second.sln Normal file
View File

@@ -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