using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
static void Main(string[] args)
CultureInfo cultureInfo = new CultureInfo("en-US");
Employee[] emp = new Employee[3];
Console.WriteLine("---------Welcome to Software Development Company---------");
for (int i = 0; i < emp.Count(); i++)
Console.WriteLine("------Enter software developer " + (i + 1) + " details-----");
emp[i].EnterDeveloperName();
emp[i].EnterGrossMonthlyPay();
emp[i].EnterEmployeeType();
emp[i].CalculateGrossAnnualPay();
Console.WriteLine("Display <1>");
Console.WriteLine("Exit <2>");
Console.Write("Choose an option : ");
string choice = Console.ReadLine();
for (int i = 0; i < emp.Count(); i++)
Console.WriteLine("------Software Developer " + (i + 1) + " Details-----");
Console.WriteLine("|Developer Name : " + emp[i].DeveloperName);
Console.WriteLine("|Zipcode : " + emp[i].ZipCode);
Console.WriteLine("|Employee Type : " + emp[i].EmployeeType);
Console.WriteLine("|Gross Monthly Pay : " + string.Format(cultureInfo, "{0:C}", emp[i].GrossMonthlyPay));
Console.WriteLine("|Gross Annual Pay : " + string.Format(cultureInfo, "{0:C}", emp[i].GrossAnnualPay));
Console.WriteLine("|Monthly Tax Amount : " + string.Format(cultureInfo, "{0:C}", emp[i].MonthlyTax));
Console.WriteLine("|Annual Tax Amount : " + string.Format(cultureInfo, "{0:C}", emp[i].AnnualTax));
Console.WriteLine(choice + " is invalid, Options are 1 or 2");
public string DeveloperName
public double GrossMonthlyPay
public double GrossAnnualPay
public string EmployeeType
public const int TaxPercentage = 14;
public void EnterDeveloperName()
Console.Write("Please enter the name: ");
string name = Console.ReadLine();
if (string.IsNullOrEmpty(name))
Console.WriteLine("Name cannot be empty");
else if (Regex.Match(name, "[0-9]*[\\^$.|?*+()!@#%&]").Success || Regex.Match(name, "[0-9]").Success)
Console.WriteLine(name + " is invalid,Type only alphabets");
public void EnterZipCode()
Console.Write("Please enter the zipcode of length five: ");
string zipcode = Console.ReadLine();
if (string.IsNullOrEmpty(zipcode))
Console.WriteLine("Zipcode cannot be empty");
if (Regex.Match(zipcode, "[a-zA-Z]*[\\^$.|?*+()!@#%&]").Success || Regex.Match(zipcode, "[a-zA-Z]").Success || zipcode.Length < 5 || zipcode.Length > 5)
if (zipcode.Length > 5 || zipcode.Length < 5)
Console.WriteLine(zipcode + " is invalid,Enter numeric zipcode of length five");
Console.WriteLine(zipcode + " is invalid,Type only numbers");
ZipCode = Convert.ToInt32(zipcode);
public void EnterGrossMonthlyPay()
Console.Write("Please enter the gross monthly pay: ");
string grossmonthlypay = Console.ReadLine();
if (string.IsNullOrEmpty(grossmonthlypay))
Console.WriteLine("Gross monthly pay cannot be empty");
else if (Regex.Match(grossmonthlypay, "[a-zA-Z]*[\\^$.|?*+()!@#%&]{5}").Success || Regex.Match(grossmonthlypay, "[a-zA-Z]").Success)
Console.WriteLine(grossmonthlypay + " is invalid,Type only numbers");
GrossMonthlyPay = Convert.ToDouble(grossmonthlypay);
public void CalculateGrossAnnualPay()
GrossAnnualPay = GrossMonthlyPay * 12;
public void EnterEmployeeType()
Console.Write("Enter employee type : ");
string EmpType = Console.ReadLine();
if (string.IsNullOrEmpty(EmpType))
Console.WriteLine("Employee type cannot be empty");
else if (EmpType == "w2" || EmpType == "W2")
else if (EmpType == "1099")
Console.WriteLine(EmpType + " is invalid, Enter W2 or 1099");
public void CalculatedTax()
if (EmployeeType == "1099")
MonthlyTax = GrossMonthlyPay * TaxPercentage / 100;
AnnualTax = MonthlyTax * 12;