I ran into another problem using if looping.
What I want to do, in plain english, is if a variable is one thing (it will be Quit in this case), exit the program. Otherwise, I want it to ask for any other inputs and execute the program.
My code:
using System;
using SC = System.Console;
// Namespace
namespace payroll
{
// Class
class payroll
{
// Method start
static void Main(string[] args)
{
// Declare variables
double hoursWorked = 0.0, payRate = 0.0, grossPay = 0.0, stateTax = 0.0;
double federalTax = 0.0, ficaTax = 0.0, netPay = 0.0;
string hoursWorkedStr, payRateStr, empName;
SC.WriteLine("Payroll Application");
//Input
SC.Write("\nPlease input Employee's Name (or Quit to end program): ");
if(empName != Quit)
{
SC.Write("\nPlease input hours worked: ");
hoursWorkedStr = Console.ReadLine();
hoursWorked = Convert.ToDouble(hoursWorkedStr);
SC.Write("\nPlease input rate of pay: ");
payRateStr = Console.ReadLine();
payRate = Convert.ToDouble(payRateStr);
//Calculations
grossPay = (hoursWorked * payRate);
stateTax = (grossPay * 0.04);
federalTax = (grossPay * 0.23);
ficaTax = (grossPay * 0.14);
netPay = (grossPay - (stateTax + federalTax + ficaTax));
//Output
SC.WriteLine("\nThe gross pay is: {0:f}", grossPay);
SC.WriteLine("\nThe state tax is: {0:f}", stateTax);
SC.WriteLine("\nThe federal tax is: {0:f}", federalTax);
SC.WriteLine("\nThe fica tax is: {0:f}", ficaTax);
SC.WriteLine("\nThe net pay is: {0:f}", netPay);
SC.WriteLine("\nEnd of Program");
else
return 0;
}
}
}
}
But everytime I try to use Quit, VS has a fit, same with else. Please help.