New to C#. This is the code I am working with:
using SC = System.Console;
public class Lab01
{ // Main Method
public static void Main()
{
string hoursWorkedAsString;
string payRateAsString;
double hoursWorked = 24;
double payRate = 11.5;
double grossPay = hoursWorked * payRate;
double stateTax = 0.04;
double federalTax = 0.23;
double ficaTax = 0.14;
double totalTax = grossPay * (stateTax + federalTax + ficaTax);
double netPay = grossPay - totalTax;
SC.WriteLine("Lab 4");
SC.WriteLine();
//get input
SC.Write("Please input hours worked: ");
hoursWorkedAsString = SC.ReadLine();
hoursWorked = System.Convert.ToDouble(hoursWorkedAsString);
SC.WriteLine();
SC.Write("Please rate of pay: ");
payRateAsString = SC.ReadLine();
payRate = System.Convert.ToDouble(payRateAsString);
SC.WriteLine();
SC.Write("Gross Pay is: ");
SC.WriteLine(hoursWorked * payRate);
SC.WriteLine();
SC.Write("State tax is: ");
SC.WriteLine(stateTax * grossPay);
SC.WriteLine();
SC.Write("Federal tax is: ");
SC.WriteLine(federalTax * grossPay);
SC.WriteLine();
SC.Write("FICA tax is: ");
SC.WriteLine(ficaTax * grossPay);
SC.WriteLine();
SC.Write("Net Pay is: ");
SC.WriteLine(grossPay - totalTax);
SC.WriteLine();
SC.Write("End of Lab 4");
SC.WriteLine();
}
}
Everything works out fine... IF I use thnumbers I declared for hoursWorked and payRate.
My question is how do I set those variables to user input? Because, if I just leave it at "double hoursWorked;" and "double payRate;", it doesn't work. I've also tried the {0} operator, and that's not accepted.
And yes, it is homework, but I've done 99% of it already.