Question: I need a flow chart for the following code that follows proper use of shapes //include header files #include #include #include #include using namespace std;
I need a flow chart for the following code that follows proper use of shapes
//include header files
#include
#include
#include
#include
using namespace std;
//constant size
#define SIZE 5
//function prototypes
int menu();
void printReport(string fName[], string lName[],
int id[], int hours[], int payrate[]);
void search(string fName[], string lName[],
int id[], int hours[], int payrate[]);
void calculatePay(string fName[], string lName[],
int id[], int hours[], int payrate[]);
void orderByLastName(string fName[], string lName[],
int id[], int hours[], int payrate[]);
void orderByid(string fName[], string lName[],
int id[], int hours[], int payrate[]);
int main()
{
//parallel arrays
string firstName[SIZE];
string lastName[SIZE];
int id[SIZE];
int hoursWorked[SIZE];
int payRate[SIZE];
//read input data from user
for (int index = 0; index { cout << "Enter first name : "; cin >> firstName[index]; cout << "Enter last name : "; cin >> lastName[index]; //input validation for id, hours and payrate do { cout << "Enter id : "; cin >> id[index]; if (id[index]<0) cout << "Invalid Id number. " << endl; } while (id[index]<0); do { cout << "Enter hours worked: "; cin >> hoursWorked[index]; if (hoursWorked[index]<0) cout << "Invalid hours. " << endl; } while (hoursWorked[index]<0); do { cout << "Enter Pay Rate : "; cin >> payRate[index]; if (payRate[index]<0) cout << "Invalid pay rate. " << endl; } while (payRate[index]<0); } //shows menu options until user enters exit the program while (true) { //call menu to show menu of options int ch = menu(); //select the appropriate option switch (ch) { case 1: printReport(firstName, lastName, id, hoursWorked, payRate); break; case 2: search(firstName, lastName, id, hoursWorked, payRate); break; case 3: int sortType; cout << "1.Sort by Last Name ."; cout << "2.Sort by id ."; cin >> sortType; if (sortType == 1) orderByLastName(firstName, lastName, id, hoursWorked, payRate); else orderByid(firstName, lastName, id, hoursWorked, payRate); break; case 4: calculatePay(firstName, lastName, id, hoursWorked, payRate); break; case 5: exit(0); } } system("pause"); return 0; } //Method to print menu int menu() { int choice; cout << "1.Print out Employee Report. " << endl; cout << "2.Search Employee Records. " << endl; cout << "3.Display the Report in Sorted order on Last Name or ID. " << endl; cout << "4.Calculate Pay. " << endl; cout << "5.Quit" << endl; cout << "Enter your choice. "; cin >> choice; return choice; } //Method to print pay amount void calculatePay(string fName[], string lName[], int id[], int hours[], int payrate[]) { ios::fixed; for (int index = 0; index cout << setw(10) << fName[index] << setw(10) << lName[index] << setw(10) << id[index] << setw(10) << hours[index] << setw(10) << payrate[index] << setw(10) << hours[index] * payrate[index] << endl; } //Method to sort the employee data order by last name void orderByLastName(string fName[], string lName[], int id[], int hours[], int payrate[]) { for (int i = 0; i { for (int j = 0; j { if (lName[j]>lName[j + 1]) { string temp = lName[j]; lName[j] = lName[j + 1]; lName[j + 1] = temp; temp = fName[j]; fName[j] = fName[j + 1]; fName[j + 1] = temp; int tempid = id[j]; id[j] = id[j + 1]; id[j + 1] = tempid; int temphours = hours[j]; hours[j] = hours[j + 1]; hours[j + 1] = temphours; int temppayrate = payrate[j]; payrate[j] = payrate[j + 1]; payrate[j + 1] = temppayrate; } } } } //Method to sort the employee data order by id void orderByid(string fName[], string lName[], int id[], int hours[], int payrate[]) { for (int i = 0; i { for (int j = 0; j { if (id[j]>id[j + 1]) { string temp = lName[j]; lName[j] = lName[j + 1]; lName[j + 1] = temp; temp = fName[j]; fName[j] = fName[j + 1]; fName[j + 1] = temp; int tempid = id[j]; id[j] = id[j + 1]; id[j + 1] = tempid; int temphours = hours[j]; hours[j] = hours[j + 1]; hours[j + 1] = temphours; int temppayrate = payrate[j]; payrate[j] = payrate[j + 1]; payrate[j + 1] = temppayrate; } } } } //Method that prompts user id and prints the employee record if found //otherwise print record not found void search(string fName[], string lName[], int id[], int hours[], int payrate[]) { bool found = false; int idNumber; int pos = -1; cout << "Enter id number "; cin >> idNumber; for (int index = 0; index { if (id[index] == idNumber) { found = true; pos = index; } } if (!found) cout << "Not found. " << endl; else cout << setw(10) << fName[pos] << setw(10) << lName[pos] << setw(10) << id[pos] << setw(10) << hours[pos] << setw(10) << payrate[pos] << endl; } //print the employees in a formatted order void printReport(string fName[], string lName[], int id[], int hours[], int payrate[]) { ios::fixed; for (int index = 0; index cout << setw(10) << fName[index] << setw(10) << lName[index] << setw(10) << id[index] << setw(10) << hours[index] << setw(10) << payrate[index] << endl; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
