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

Using this data file (salesdata.txt), complete the following tasks: We will use

ID: 3723192 • Letter: U

Question

Using this data file (salesdata.txt), complete the following tasks:

We will use the following arrays for this class project.

names as string

empID as C-string with length of 5    ( hint declare as char array )

wages as double

unitsSold as integer

Write a function, fillArray, that fills the elements of each array from a data file, salesdata.txt, located in C:classdata (create a folder C:classdata on your computer). Hint: Examine the format of the data file before designing your solution.

Write a function, displayTable, that displays the elements of the arrays in a tabular format

Write a function, searchID, that searches for an empID and returns the index. If the empID is not found return -1. Make sure to accept a reference integer parameter.

Write a function, displayEmployee, that accepts the index of the searchID result then displays all of the information about a single employee, in form layout, based on the index. If the index is -1 then display a friendly error message like “Error: Employee not found”

Write a function, changeUnitSold, that accepts the index of the searchID result then changes the value of unitsSold of a single employee based on the index of the empID. If index is -1 then change nothing

Write a function, changeWage, that accepts the index of the searchID result then changes the value of wages of a single employee based on the index of the empID. If index is -1 then change nothing.

Write a function, sortByEmpID, that organizes the arrays in ascending order based on empID values. (Use the bubble sort method)

Write a function, searchName, that searches for all occurrences of a name that begins with a specific letter. Store the subscripts in an array called searchResults that stores up to 20 elements then display the list on the screen.

Write a main function that calls fillArray then displays a menu that looks like this. The highlighted text is the user input

Call functions based on user’s menu selection. Allow the user to run the program and display the menu until choice G is selected that terminates the program.

given code

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;

int searchResults[20];

void fillArray(string n[], char eid[][6], double w[], int us[], int lsize);

void displayTable(string n[], char eid[][6], double w[], int us[], int lsize);

void searchID(char eid[][6], int lsize, int &index);

void displayEmployee(string n[], char eid[][6], double w[], int us[], int index);

void changeUnitSold(int us[], int index);

void changeWage(double w[], int index);

void sortByEmpID(string n[], char eid[][6], double w[], int us[], int lsize);

void searchName(string n[], int lsize);

int main()
{
  
return 0;
}

information inside of sales data

John P.
Mary Q.
Sam T.
Tom L.
Lisa O.
Teresa A.
Peter B.
Harris W.
Marcia D.
John G.
Lawrence F.
Amin C.
Jeffrey N.
Maria Z.
Cuong N.
Fila H.
Clark R.
Pedro J.
Jamie O.
Kevin Y.
a1253
a2736
b8293
f5261
b2263
m9283
c5278
c1263
a1426
b7722
a6623
b1192
b5261
m1928
f7262
a3421
a7827
a9928
b7893
c7776
16.96
16.96
19.21
25.45
19.21
56.95
18.23
18.36
16.24
19.78
16.3
19
19
56.95
25.45
16.96
16.96
16.96
19.21
18.36
2035
1258
9652
525
3489
4156
4336
4570
4803
5037
5270
5504
5737
5970
6204
6437
6671
6904
7138
7371

Explanation / Answer

#include <iostream>

#include <fstream>

#include <string>

#include <iomanip>

using namespace std;

int searchResults[20];

string name[];

char empid[][6];

double wg[];

int units[];

int size = 20;

void fillArray(string n[], char eid[][6], double w[], int us[], int lsize);

void displayTable(string n[], char eid[][6], double w[], int us[], int lsize);

void searchID(char eid[][6], int lsize, int &index);

void displayEmployee(string n[], char eid[][6], double w[], int us[], int index);

void changeUnitSold(int us[], int index);

void changeWage(double w[], int index);

void sortByEmpID(string n[], char eid[][6], double w[], int us[], int lsize);

void searchName(string n[], int lsize);

int main()

{

char choice='y';

int op;

while(choice=='y' || choice =='Y'){

displayMenu();

cin>>op;

  

switch(op){

case 1: fillArray(name,empid,wg,units,size);

break;

case 2: displayTable(name,empid,wg,units,size);

break;

case 3:

char eid[6];

cout<<"Enter employee ID to be searched";

cin>>eid;

int idIndex = searchID(empid,size,eid);

cout<<"Employee found at index"<<idIndex<<endl;

break;

case 4:

int index;

cout<<"Enter an index for employee";

cin>>index;

displayEmployee(name,empid,wg,units,index);

break;

case 5:

int ind;

cout<<"Enter an index for updating unit sold. Increasing the units sold by 10.";

cin>>ind;

changeUnitSold(units,ind);

break;

case 6:

int indw;

cout<<"Enter an index for updating wages. Increasing the wage sold by 2.";

cin>>indw;

changeUnitSold(units,indw);

break;

case 7:

sortByEmpID(name,empid,wg,units,size);

break;

case 8:

searchName(name,size);

break;

case 9: exit(0);

}

cout<<"Enter Y/y to continue"<<endl;

cin>>choice;

}

return 0;

}

void displayMenu(){

cout<<"MENU"<<endl;

cout<<"1.Fill the array"<<endl;

cout<<"2.Display table"<<endl;

cout<<"3.Search ID"<<endl;

cout<<"4.Display employee"<<endl;

cout<<"5.Change unit sold"<<endl;

cout<<"6.Change wage"<<endl;

cout<<"7.Sort by Employee ID"<<endl;

cout<<"8.Search Name"<<endl;

cout<<"9.to quit"<<endl;

}

void fillArray(string n[], char eid[][6], double w[], int us[], int lsize){

ifstream infile;

infile.open(" C:classdatasalesdata.txt");

string line;

for(int i=0; i<20;i++){

n[i] = getline(infile, line);

}

for( i=0; i<20;i++){

eid[i] = getline(infile, line);

}

for( i=0; i<20;i++){

w[i] = getline(infile, line);

}

for( i=0; i<20;i++){

us[i] = getline(infile, line);

}

}

void displayTable(string n[], char eid[][6], double w[], int us[], int lsize){

cout<<"Name Employee ID Wages Units Sold"<<endl;

for(int i=0; i<20;i++){

cout<<n[i]<<" "<<eid[i]<<" "<<w[i]<<" "<<us[i]<<endl;

}

}

int searchID(char eid[][6], int lsize, char eId[]){

for(int i=0;i<lsize;i++){

for(int j=0;i<6;j++){

if(eid[i][j] == eId[j])

continue;

else

break;

}

if(j==6)

return i;

}

return -1;

}

void displayEmployee(string n[], char eid[][6], double w[], int us[], int index{

cout<<<<n[index]<<" "<<eid[index]<<" "<<w[index]<<" "<<us[index]<<endl;

}

void changeUnitSold(int us[], int index){

us[index] = us[index] + 10;

}

void changeWage(double w[], int index){

w[index] = w[index] + 2;

}

void sortByEmpID(string n[], char eid[][6], double w[], int us[], int lsize){

for(k=0; k< lsize; k++) {

for (i = 0; i < 6; i++) {

for (j = i +1; j < 6; ++j) {

if (eid[k][i] > eid[k][j]) {

int swap = eid[k][i];

eid[k][i] = eid[k][j];

eid[k][j] = swap;

}

}

}

}

}

void searchName(string n[], int lsize){

char first;

cout<<"Enter a character";

cin>first;

string tempNames[20];

int in=0;

for(int i=0; i<lsize; i++){

if(n[i].charAt(0) == first)

tempNames[in++] = n[i];

}

cout<<"Names starting from"<<first<<endl;

for(int i=0; i<in; i++){

cout<<tempNames[i]<<endl;

}

}