With this project that was covered earlier for me is suppose to be treat it like
ID: 3703589 • Letter: W
Question
With this project that was covered earlier for me is suppose to be treat it like a component that is not ready! Mock the interface (various input/output combinations) so that other software components can be tested meaningfully.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DebugFixMethods
{
class Program
{
static void Main(string[] args)
{
const double FEDERAL_TAX_RATE = 0.28; const double SOCIAL_SECURITY_RATE = 0.0765;
{
Console.WriteLine(" WEEKLY PAYROLL INFORMATION");
Console.WriteLine(" --------------------------");
Console.Write(" Please enter the employer's name: ");
string empName = Console.ReadLine();
Console.Write(" Please enter the number of hours worked this week: ");
double hrsWorked = Convert.ToDouble(Console.ReadLine());
Console.Write(" Please enter the number of OVERTIME HOURS worked this week: ");
double ovtWorked = Convert.ToInt32(Console.ReadLine()); Console.Write(" Please enter employee's HOURLY PAY RATE: ");
double payRate = Convert.ToDouble(Console.ReadLine()); double grossPay = CalculateGrossPay(hrsWorked, payRate, ovtWorked);
double federalTaxWithheld = CalculateTax(grossPay, FEDERAL_TAX_RATE);
double socialSecurityWithheld = CalculateTax(grossPay, SOCIAL_SECURITY_RATE);
double netPay = CalculateNetPay(grossPay, federalTaxWithheld + socialSecurityWithheld);
Console.WriteLine(" The weekly payroll information summary for: " + empName);
Console.WriteLine(" Gross pay: {0:C2} ", grossPay);
Console.WriteLine(" Federal income taxes witheld: {0:C2} ", federalTaxWithheld);
Console.WriteLine(" Social Security taxes witheld: {0:C2} ", socialSecurityWithheld);
Console.WriteLine(" Net Pay: {0:C2}", netPay);
Console.ReadLine();
}
double CalculateGrossPay(double HoursWorked, double PayRate, double OvertimeHoursWorked)
{
return PayRate * (HoursWorked + 1.5 * OvertimeHoursWorked);
}
double CalculateTax(double GrossPay, double TaxRate)
{
return GrossPay * TaxRate;
}
double CalculateNetPay
(double GrossPay, double TaxAmount
)
{
return GrossPay - TaxAmount;
}
}
}
}
Explanation / Answer
/* program after rectification of code is"
using System.IO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DebugFixMethods
{
class test
{
public double CalculateGrossPay(double HoursWorked, double PayRate, double OvertimeHoursWorked)
{
return PayRate * (HoursWorked + 1.5 * OvertimeHoursWorked);
}
public double CalculateTax(double GrossPay, double TaxRate)
{
return GrossPay * TaxRate;
}
public double CalculateNetPay
(double GrossPay, double TaxAmount
)
{
return GrossPay - TaxAmount;
}
}
class Program
{
static void Main(string[] args)
{
const double FEDERAL_TAX_RATE = 0.28; const double SOCIAL_SECURITY_RATE = 0.0765;
var t=new test();
Console.WriteLine(" WEEKLY PAYROLL INFORMATION");
Console.WriteLine(" --------------------------");
Console.Write(" Please enter the employer's name: ");
string empName = Console.ReadLine();
Console.Write(" Please enter the number of hours worked this week: ");
double hrsWorked = Convert.ToDouble(Console.ReadLine());
Console.Write(" Please enter the number of OVERTIME HOURS worked this week: ");
double ovtWorked = Convert.ToInt32(Console.ReadLine()); Console.Write(" Please enter employee's HOURLY PAY RATE: ");
double payRate = Convert.ToDouble(Console.ReadLine());
double grossPay = t.CalculateGrossPay(hrsWorked, payRate, ovtWorked);
double federalTaxWithheld = t.CalculateTax(grossPay, FEDERAL_TAX_RATE);
double socialSecurityWithheld = t.CalculateTax(grossPay, SOCIAL_SECURITY_RATE);
double netPay = t.CalculateNetPay(grossPay, federalTaxWithheld + socialSecurityWithheld);
Console.WriteLine(" The weekly payroll information summary for: " + empName);
Console.WriteLine(" Gross pay: {0:C2} ", grossPay);
Console.WriteLine(" Federal income taxes witheld: {0:C2} ", federalTaxWithheld);
Console.WriteLine(" Social Security taxes witheld: {0:C2} ", socialSecurityWithheld);
Console.WriteLine(" Net Pay: {0:C2}", netPay);
Console.ReadLine();
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.