I'm getting this error in my code, i'm trying to make the user input the employees name and how much they earn than the earning goes through all the tax maths and then gives the user an output of the name entered and the take home pay - taxs. I have to use two classes. Where am I going wrong? Please help.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace consoleapplication9
{
public class takehomepay
{
static void Main(String[] args)
{
const decimal commission = 0.7M; // Commision rate
const decimal federaltax = 0.18M; // federal tax rate
const decimal retirement = 0.10M; // retirement rate
const decimal socialsecurity = 0.06M; // social security rate
string employeeName;
decimal commcost = 0; // commision cost
decimal fedtaxcost = 0; // federal tax cost
decimal retirecost = 0; // retirement cost
decimal socseccost = 0; // social security cost
decimal totalwithholdingcost = 0; // total withholding
decimal takehomepay = 0; // amount taken home
decimal totalSales = 0;
Console.Write("\nEnter employees name: ");
employeeName = Console.ReadLine();
Console.Write("Enter the total sales amount for the week:");
totalSales = Convert.ToDecimal(Console.ReadLine());
var employee = new Employee(employeeName, totalSales);
Console.Write(employee);
Console.Read();
//Calculations
commcost = commission * totalSales;
fedtaxcost = federaltax * commcost;
retirecost = retirement * commcost;
socseccost = socialsecurity * commcost;
totalwithholdingcost = federaltax + retirement + socialsecurity;
takehomepay = commcost - totalwithholdingcost;
}
}
public class Employee
{
private string employeeName;
private decimal totalSales;
public Employee()
{
}
public Employee(string Name)
{
employeeName = Name;
}
public Employee(string Name, decimal Sales)
{
employeeName = Name;
totalSales = Sales;
}
public string EmployeeName
{
get
{
return employeeName;
}
set
{
employeeName = value;
}
}
public decimal takehomepay
{
get
{
return takehomepay;
}
set
{
takehomepay = value;
}
}
public override string ToString()
{
return "Employee: " + employeeName +
"\nTake home pay: " + takehomepay;
}
}
}