Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USE visual studio 2013 c++ Write a program to create a list of employees by stor

ID: 646054 • Letter: U

Question

USE visual studio 2013 c++

Write a program to create a list of employees by storing their information in the following arrays:

empId: an array of long integers to hold the employee numbers.

hours: an array of integers to hold each employee's hours worked.

payRate: an array of double to hold each employee's pay rate.

wages: an array of double to hold each employee's wage (payRate x hours).

The program should relate the data in each array through the subscripts. For example, the number in element 0 of the hours array should be the hours worked of the employee whose number is stored in element 0 of the empId array. Similarly with the other arrays. Create a constant for the array size to be used by all the arrays.

When the program is run, it first calls a function to display a menu as follows:

There are 6 functions:

showMenu: display the menu above.

addEmployee: when 1 is selected, this function asks the user to enter the employee number, hours worked and pay rate. They are stored in their respective arrays. Keep track of the total number of employees entered (how many elements have values) to be used by the listEmployee function. After each input, ask the user if he/she wants to add more. If yes, make sure that the total number of inputs does not exceed the array size before proceeding to ask the user to enter again. If no, return to display the menu.

updateEmployee: when 2 is selected, this function asks the user to enter the employee number. It searches for the number in the empId array. If found, display the number and ask the user to enter the hours worked and pay rate.

retrieveEmployee: when 3 is selected, this function asks the user to enter the employee number. It searches for the number in the empId array. If found, display the number, hours worked, pay rate, and wage.

listEmployee: when 4 is selected, this function traverses the arrays and displays each employee information (number, hours worked, pay rate, and wage). Make sure to display only the elements that have values. Do not use the whole array size if the arrays are not filled up. Make sure to format the output as shown below.

searchList: this function performs a linear search on an integer array. It is called by updateEmployee and retrieveEmployee functions.

Input Validation: Accept only value between 1 and 5 for the menu choice. The hours worked must be positive. The pay rate must be at least 6.

Do not use global variables. You can use a global constant if you want. That's all. Learn to pass by reference if necessary. Do not pass reference everything because you like to. Pass by reference only when the variale is modified. Do not use break, continue, exit and return from an if (the only return is from a function. So only one return and not twice or several in a function).

The display should look like the following (make sure to format it correctly):

Include in your program the following comments:

Name of program

Programmer's name

Brief description of the program

Comments for all the statements

Optional (I believe you should do it, but it's OK if you don't do it): Create an IPO chart. List the input, processing, and output items.

Optional: Plan the algorithm using pseudocode.

Save the program in a filename LastFirst_final.cpp

Compile and run the program.

Take a screen shot of the output. Save it in a filename LastFirst_final.doc (e.g. DoeJoe_final.doc)

Submit LastFirst_final.cpp and LastFirst_final.doc by uploading them in Catalyst.

Explanation / Answer

#include
#include

using namespace std;

int addEmployee(long int emp[20],int hours[20],double wages[20],double payrate[20]);
void updateEmployee(long int emp[20],int hours[20],double wages[20],double payrate[20]);
void retrieveEmployee(long int emp[20],int hours[20],double wages[20],double payrate[20]);
void showMenu();
void listEmployee(long int emp[20],int hours[20],double wages[20],double payrate[20],int n);
void main()
{
showMenu();

    std::cin.ignore( std::numeric_limits::max(), ' ' );
   getch();
}
void showMenu()
{
long int emp[20];
int hours[20];
double wages[20],payrate[20];

int choice,n;
cout<<" Employee Payroll "<


do
{
cout<<" 1. Add employee "< cout<<"2. Update employee "< cout<<"3. Retrieve employee"< cout<<"4. List all"< cout<<"5. Quit the Program"<

cout<< " Enter your choice: ";
cin>>choice;
switch(choice)
{
case 1: { n=addEmployee(emp,hours,wages,payrate); } break;

case 2:{ updateEmployee(emp,hours,wages,payrate);} break;
case 3: {retrieveEmployee(emp,hours,wages,payrate);}break;
case 4: { listEmployee(emp,hours,wages,payrate,n);}break;
case 5: { exit(0);} break;
default:{ cout<<"Enter proper choice:"< }
}
while(choice!=5);
}

void listEmployee(long int emp[20],int hours[20],double wages[20],double payrate[20],int n)
{
   for(int i=0;i    {
       cout<<" Employee Id Hours Payrate Wages "<

       cout<<" "<    }
}

void updateEmployee(long int emp[20],int hours[20],double wages[20],double payrate[20])
{
   int id,search;
   cout<<"Enter the Employee Id No:"<    cin>>id;

   for(int i=0;i<20;i++)
   {
       if(id==emp[i])
           search=i;
   }
   cout<<"Enter the hours for the employee:"<    cin>>hours[search];
   cout<<"Enter the payrate for the employee:"<    cin>>payrate[search];

   wages[search]=hours[search]*payrate[search];
   cout<<"Updated"< }

void retrieveEmployee(long int emp[20],int hours[20],double wages[20],double payrate[20])
{

   int id,search;
   cout<<"Enter the Employee Id No:"<    cin>>id;

   for(int i=0;i<20;i++)
   {
       if(id==emp[i])
           search=i;
   }
   cout<<"Employee hours :"<    cout<<"Employee payrate :"<    cout<<"Employee wages :"< }


int addEmployee(long int emp[20],int hours[20],double wages[20],double payrate[20])
{
   static int i=0;
  
   cout<<"Enter the employees emp Id:";
   cin>>emp[i];
   cout<<"Enter the hours ";
   cin>>hours[i];
   cout<<"Enter the payrate: ";
   cin>>payrate[i];

   if(payrate[i]<6)
   {
   cout<<"Enter the payrate:";
   cin>>payrate[i];
   }
  
   if(hours[i]<=0)
{
   cout<<"Enter the hours";
   cin>>hours[i];
   }
  

  

   if(i==20)
       showMenu();

   wages[i]=hours[i]*payrate[i];
   i++;

   return i;
}