My tutor set me the task of making a C# program that
- demonstrates recursion (I think I've done that)
- uses a global variable
- can be used by a business
This is what I've come up with. It only has to be a small program, but I don't know where I can use a global variable. I was thinking something to do with subtracting tax, but every time I get started I forget what my idea was.
static void nameCheck()
{
    Console.WriteLine("Name of employee: ");
    string employee = Console.ReadLine();
    string[] employees = { "Emp1", "Emp2", "Emp3", "Emp4" };
    File.WriteAllLines("C:/Users/Chris/Documents/Visual Studio 2013/Projects/ConsoleApplication38/Employees.txt", employees);
    string[] lines = File.ReadAllLines("C:/Users/Chris/Documents/Visual Studio 2013/Projects/ConsoleApplication38/Employees.txt");
    int match = 0;
    foreach (string line in lines)
    {
        if (employee != line)
        {
            match = match + 1;
            if (match > 3)
            {
                Console.WriteLine("That name is not in the employee database, try again:");
                nameCheck();
            }
        }
    }
}
static double payRoll(double hours, double wage)
{
    double pay = hours * wage;
    return pay;
}
static void Main(string[] args)
{
    Console.WriteLine("                                   PAYROLL");
    Console.WriteLine("--------------------------------------------------------------------------------");
    nameCheck();
    Console.WriteLine("Number of hours worked this week: ");
    int hours = Convert.ToInt32(Console.ReadLine());
    const double wage = 7.50;
    double pay = payRoll(hours, wage);
    Console.WriteLine("Pay before tax for this employee is £" + pay);
    Console.ReadLine();
    }
}
 
     
     
     
     
     
    