Stuck doing a payroll calculator

GOAL: You will need to design an application that it will prompt a user for his or her hourly pay rate; his or her hours worked; and whether he or she is single, married, divorced, or widowed. It will then calculate the user’s gross and net pay. If the user works more than 40 hours, overtime is calculated at 1 ½ times the regular rate and displayed separately. If he or she is married, use a flat tax rate of 15%. If he or she is single, use 22%; if he or she is divorced, use 23%; and if he or she is widowed, use 13% (I realize that these are not very realistic). Below is a sample of what the program should do when run.

I'm pretty close to getting it, but I'm getting 5 errors of "ErrorCS0029: Cannot implicitly convert type 'string' to 'double' Payroll Calculator"

Here's the code that I have:

Console.Write("Enter the number of hours worked: "); double hours = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter the payrate:"); double payRate = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter marital status letter as (S)ingle, (M)arried, (W)idowed, or (D)ivorced:"); string maritalStatus = Console.ReadLine(); double taxRate; if (maritalStatus == ("m")) { taxRate = "0.15"; } else if (maritalStatus == ("s")) { taxRate = "0.22"; } else if (maritalStatus == ("w")) { taxRate = "0.13"; } else if (maritalStatus == ("d")) { taxRate = "0.23"; } else { Console.Write("Error with input."); } Console.ReadLine();

 double grossPay = hours * payRate; Console.Write("Your gross pay is:" + grossPay); Console.ReadLine(); // break double netPay = grossPay * (1 - (taxRate)); Console.Write("Your net pay is:" + netPay); 

by HubertJayFarnsworth via /r/csharp

Leave a Reply