using System.Collections.Generic;
public static void Main()
Console.WriteLine(@"Hello candidate!");
Console.WriteLine(@"You have been tasked with creating a method that calculates a Sales Rep's total pay based on a list of customers.");
Console.WriteLine(@"It will print out the individual pay for each customer, along with the Name of the Customer, the Customer's Grade, the Customer's Monthly Amount, and the Rep's applicable Percentage.");
Console.WriteLine(@"The criteria for this is explained in the comments below.");
List<PayrollInformation> repAccounts = new List<PayrollInformation>();
repAccounts.Add(new PayrollInformation() { CustomerId = 1, CustomerName = "TEST", CustomerGrade = 'A', CustomerMonthlyAmount = 10.99m, SalesRepId = 1, SalesRepName = "TESTSON", SalesRepPayPercentage = 0.1m } );
repAccounts.Add(new PayrollInformation() { CustomerId = 2, CustomerName = "TEST", CustomerGrade = 'B', CustomerMonthlyAmount = 10.99m, SalesRepId = 1, SalesRepName = "TESTSON", SalesRepPayPercentage = 0.1m } );
repAccounts.Add(new PayrollInformation() { CustomerId = 3, CustomerName = "TEST", CustomerGrade = 'C', CustomerMonthlyAmount = 10.99m, SalesRepId = 1, SalesRepName = "TESTSON", SalesRepPayPercentage = 0.1m } );
repAccounts.Add(new PayrollInformation() { CustomerId = 4, CustomerName = "TEST", CustomerGrade = 'D', CustomerMonthlyAmount = 10.99m, SalesRepId = 1, SalesRepName = "TESTSON", SalesRepPayPercentage = 0.1m } );
repAccounts.Add(new PayrollInformation() { CustomerId = 5, CustomerName = "TEST", CustomerGrade = 'N', CustomerMonthlyAmount = 50.99m, SalesRepId = 1, SalesRepName = "TESTSON", SalesRepPayPercentage = 0.1m } );
repAccounts.Add(new PayrollInformation() { CustomerId = 6, CustomerName = "TEST", CustomerGrade = 'N', CustomerMonthlyAmount = 30.99m, SalesRepId = 1, SalesRepName = "TESTSON", SalesRepPayPercentage = 0.1m } );
CalculatePay(repAccounts);
public static void CalculatePay(List<PayrollInformation> salesRepAccounts)
foreach(var item in salesRepAccounts)
decimal repPercent = 0.0m;
if (item.CustomerGrade == 'A' || item.CustomerGrade == 'B' || (item.CustomerGrade == 'N' && item.CustomerMonthlyAmount > 55.99m))
else if (item.CustomerGrade == 'C' || (item.CustomerGrade == 'N' && item.CustomerMonthlyAmount > 45.99m))
else if (item.CustomerGrade == 'D' || (item.CustomerGrade == 'N' && item.CustomerMonthlyAmount > 35.99m))
Console.WriteLine(string.Format("{0}: {1:c}, Grade: {2}, Monthly Amount: {3}, Rep Percent: {4:P2}"
, item.CustomerName, item.SalesRepPayPercentage * item.CustomerMonthlyAmount, item.CustomerGrade, item.CustomerMonthlyAmount, repPercent * item.SalesRepPayPercentage));
public class PayrollInformation
public int CustomerId { get; set; }
public string CustomerName { get; set; }
public char CustomerGrade { get; set; }
public decimal CustomerMonthlyAmount { get; set; }
public int SalesRepId { get; set; }
public string SalesRepName { get; set; }
public decimal SalesRepPayPercentage { get; set; }