Example #1
0
 public static void listEmployee()
 {
     if (employees.Count == 0)
     {
         Console.WriteLine("No employees.");
         return;
     }
     for (int i = 1; i <= employees.Count; i++)
     {
         Employee test = null;
         employees.TryGetValue(i, out test);
         Console.WriteLine(i + ". " + test.ToString());
     }
 }
Example #2
0
        public static void Main(string[] args)
        {
            Employee[] employees    = new Employee[10];
            int        numEmployees = 0;

            Console.WriteLine("Welcome to the employee management system!");

            while (numEmployees < 10)
            {
                Console.Write("\nWant to enter an employee's information? (y/n) ");
                string choice = Console.ReadLine();
                while (choice != "y" && choice != "n")
                {
                    Console.Write("Please enter y or n: ");
                    choice = Console.ReadLine();
                }

                if (choice == "n")
                {
                    break;
                }

                employees[numEmployees] = MakeEmployee();
                numEmployees++;
            }

            if (numEmployees == 10)
            {
                Console.WriteLine("Thanks, we're done! We can't hire more than 10 employees.");
            }

            if (numEmployees > 0)
            {
                Console.WriteLine("\nHere is the information you entered: ");
                Console.WriteLine(Employee.ColumnHeadings());
                for (int i = 0; i < numEmployees; i++)
                {
                    Employee employee = employees[i];
                    Console.WriteLine(employee.ToString());
                }
            }

            Console.WriteLine("\nThanks! Press any key to exit.");
            Console.ReadKey();
        }
Example #3
0
        static void Main(string[] args)
        {
            double   hours;
            double   wage;
            string   name;
            string   id;
            Employee employee;

            name = GetName();

            id = GetID();

            hours = GetHours();

            employee = new Employee(name, id, hours);

            wage = employee.calcWage();

            Console.WriteLine(employee.ToString());
            Console.WriteLine("The Weekly Wage is £" + wage.ToString("F"));
        }