Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You need to fix any problem with your program 1 (especially CRASHing). Follow the instructions below to update the code such as: Use collections (of


    1. You need to fix any problem with your program 1 (especially CRASHing).
    2. Follow the instructions below to update the code such as:
      1. Use collections (of your choice) instead of arrays to store data.
      2. Use LINQ to query, insert, update, delete your collections.
  1. • Create a console app using C# and .Net

    •It's an Employee management system that will perform the following:

    •Add, update, delete an employee (ID, name, address, email, phone, role)

    •Payroll feature for adding this weekswages (ID, employeeID, hours worked, hourly rate, date)

    •Vacation days (ID, employeeID, numberOfDays)

    •Each employee will be given 14 days when a new employee is added and will increment by 1 when a new payroll entry is entered for that employee.

     

    Use collections to store your data, you must use a custom class for Employee, Payroll and Vacation at minimum.

    Use LINQ to query, insert, update, delete your collections.

    •Your console application must have a hierarchy of menus and run continuously until the person quits the application:

    •Example:

    •Menu 1:

    •Welcome, please choose a command:

    •Press 1 to modify employees

    •Press 2 to add payroll

    •Press 3 to view vacation days

    •Press 4 to exit program

     

    •Menu 2: (Employees)

    •Press 1 to list all employees

    •Press 2 to add a new employee

    •Press 3 to update an employee

    •Press 4 to delete an employee

    •Press 5 to return to main menu

     

    •Menu 3: (Payroll)

    •Press 1 to insert new payroll entry

    •Press 2 view payroll history for an employee

    •Press 3 to return to main menu

     

    •Menu 4: (Vacation days)

    •Press 1 to view vacation days

    •Press 2 to return to the main menu

     

     

      • Note: all functions listed above must perform insert/update/delete/view into a collection of your choice and must use LINQ to perform the query.

    • To utilize LINQ in insert command for example, you should first query the ID to see if it is already used before or not. 
  2.  

    PROGRAM : 1


//employee class        public class Employee        {        public int Id { get; set; }        public string Name { get; set; }        public string Address { get; set; }        public string Email { get; set; }        public string Phone { get; set; }        public string Role { get; set; }        }        //payroll class        public class Payroll        {        public int Id { get; set; }        public int EmployeeId { get; set; }        public int HoursWorked { get; set; }        public int HourlyRate { get; set; }        public DateTime Date { get; set; }        }        //vacation days class        public class VacationDays        {        public int Id { get; set; }        public int EmployeeId { get; set; }        public int NumberOfDays { get; set; }        }        //main program        class Program        {        static void Main(string[] args)        {        //array for storing employee data        Employee[] employees = new Employee[100];        int employeeCount = 0;        //array for storing payroll data        Payroll[] payrolls = new Payroll[100];        int payrollCount = 0;        //array for storing vacation days data        VacationDays[] vacationDays = new VacationDays[100];        int vacationDaysCount = 0;        while (true)        {        //display main menu        Console.WriteLine("Welcome, please choose a command:");        Console.WriteLine("Press 1 to modify employees");        Console.WriteLine("Press 2 to add payroll");        Console.WriteLine("Press 3 to view vacation days");        Console.WriteLine("Press 4 to exit program");        //get input from user        string input = Console.ReadLine();        //process input        if (input == "1")        {        //display employees menu        Console.WriteLine("Press 1 to list all employees");        Console.WriteLine("Press 2 to add a new employee");        Console.WriteLine("Press 3 to update an employee");        Console.WriteLine("Press 4 to delete an employee");        Console.WriteLine("Press 5 to return to main menu");        //get input from user        input = Console.ReadLine();        //process input        if (input == "1")        {        //list all employees        foreach (var employee in employees)        {        if (employee != null)        {        Console.WriteLine($"ID: {employee.Id}");        Console.WriteLine($"Name: {employee.Name}");        Console.WriteLine($"Address: {employee.Address}");        Console.WriteLine($"Email: {employee.Email}");        Console.WriteLine($"Phone: {employee.Phone}");        Console.WriteLine($"Role: {employee.Role}");        Console.WriteLine();        }        }        }        else if (input == "2")        {        //add new employee        //create new employee object        Employee employee = new Employee();        //set employee id        employee.Id = employeeCount + 1;        Console.WriteLine("Enter employee name:");        employee.Name = Console.ReadLine();        Console.WriteLine("Enter employee address:");        employee.Address = Console.ReadLine();        Console.WriteLine("Enter employee email:");        employee.Email = Console.ReadLine();        Console.WriteLine("Enter employee phone:");        employee.Phone = Console.ReadLine();        Console.WriteLine("Enter employee role:");        employee.Role = Console.ReadLine();        //add employee to array        employees[employeeCount] = employee;        employeeCount++;        Console.WriteLine($"Employee {employee.Name} added successfully!");        }        else if (input == "3")        {        //update employee        //get employee id        Console.WriteLine("Enter employee id:");        int id = int.Parse(Console.ReadLine());                 //get employee from array        Employee employee = employees[id - 1];        if (employee != null)        {        //update employee name        Console.WriteLine("Enter employee name:");        employee.Name = Console.ReadLine();        //update employee address        Console.WriteLine("Enter employee address:");        employee.Address = Console.ReadLine();        //update employee email        Console.WriteLine("Enter employee email:");        employee.Email = Console.ReadLine();        //update employee phone        Console.WriteLine("Enter employee phone:");        employee.Phone = Console.ReadLine();        //update employee role        Console.WriteLine("Enter employee role:");        employee.Role = Console.ReadLine();        Console.WriteLine($"Employee {employee.Name} updated successfully!");        }        else        {        Console.WriteLine("Employee not found!");        }        }        else if (input == "4")        {        //delete employee        //get employee id                 Console.WriteLine("Enter employee id:");        int id = int.Parse(Console.ReadLine());        //get employee from array        Employee employee = employees[id - 1];        if (employee != null)        {        //delete employee        employees[id - 1] = null;        Console.WriteLine($"Employee {employee.Name} deleted successfully!");        }        else        {        Console.WriteLine("Employee not found!");        }        }        else if (input == "5")        {        //return to main menu        break;        }        else        {        Console.WriteLine("Invalid input");        }        }        else if (input == "2")        {        //add payroll        //create new payroll object        Payroll payroll = new Payroll();        //set payroll id        payroll.Id = payrollCount + 1;        //get employee id        Console.WriteLine("Enter employee id:");        payroll.EmployeeId = int.Parse(Console.ReadLine());        //get hours worked        Console.WriteLine("Enter hours worked:");        payroll.HoursWorked = int.Parse(Console.ReadLine());        //get hourly rate        Console.WriteLine("Enter hourly rate:");        payroll.HourlyRate = int.Parse(Console.ReadLine());        //get date        Console.WriteLine("Enter date:");        payroll.Date = DateTime.Parse(Console.ReadLine());        //add payroll to array        payrolls[payrollCount] = payroll;        payrollCount++;        Console.WriteLine($"Payroll {payroll.Id} added successfully!");        }        else if (input == "3")        {        //view vacation days        //get employee id        Console.WriteLine("Enter employee id:");        int id = int.Parse(Console.ReadLine());        //get employee from array        Employee employee = employees[id - 1];        if (employee != null)        {        //display vacation days        Console.WriteLine($"Vacation days for {employee.Name}: {employee.VacationDays}");        }        else        {        Console.WriteLine("Employee not found!");        }        }        else if (input == "4")        {        //exit program        Environment.Exit(0);        }        else        {        Console.WriteLine("Invalid input");        }        }        }        }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Computer Network questions

Question

What areas of knowledge do I have?

Answered: 1 week ago