Note that there are some explanatory texts on larger screens.

plurals
  1. POc# using operators with calculations (net pay) (gross pay)
    text
    copied!<p>I don't understand if the calculation for <code>netPay = grossPay - (fedtax withholding + social security tax withholding)</code>. Are my calculations correct within the program? Dealing with such in <code>editedTax</code>?? If someone could help I'd appreciate it.</p> <p><strong>More info</strong>: When I display <code>netPay</code> within an output, I receive a runtime error, where I couldn't convert the negative to currency with <code>{0:c2}</code>.</p> <pre><code>using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication5 { class Program { static void Main(string[] args) { string empName; string userInput; double netPay; double editedTax1; double grossPay; double editedTax2; double hrsWorked; double ovtWorked; double payRate; const double FED_TAX = .28; const double SS_TAX = 7.65; // step 1 Console.WriteLine(" WEEKLY PAYROLL INFORMATION"); // step 2 Console.WriteLine(" --------------------------"); // step 3 Console.Write("\n Please enter the employer's name: "); empName = Console.ReadLine(); //step 4 Console.Write("\n Please enter the number of hours worked this week: "); userInput = Console.ReadLine(); hrsWorked = Convert.ToDouble(userInput); // step 5 Console.Write("\n Please enter the number of OVERTIME HOURS worked this week: "); userInput = Console.ReadLine(); ovtWorked = Convert.ToInt32(userInput); // step 6 Console.Write("\n Please enter employee's HOURLY PAY RATE: "); userInput = Console.ReadLine(); payRate = Convert.ToDouble(userInput); // step 7 grossPay = (hrsWorked * payRate + ovtWorked * 1.5 * payRate); // step 8 editedTax1 = FED_TAX * grossPay; // step 9 editedTax2 = SS_TAX * grossPay; // step 10 netPay = editedTax1 + editedTax2 - grossPay; // step 11 Console.WriteLine("\n\n The weekly payroll information summary for: " + empName); Console.WriteLine("\n Gross pay: {0:C2} ", grossPay); // step 12 Console.WriteLine(" Federal income taxes witheld: {0:C2} ", editedTax1); Console.WriteLine(" Social Security taxes witheld: {0:C2} ", editedTax2); Console.WriteLine(" Net Pay: {0:C2}", netPay); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload