Question: In this c++ coding, I put 20 as the limit. But it seems like did not function, if I put 20 input, it still display

In this c++ coding, I put 20 as the limit. But it seems like did not function, if I put 20 input, it still display . Please fix my errors so it will display " exceed the limit" in coding.

******Employee.cpp*****

#include #include #include #include"Employee.h" using namespace std;

Employee::Employee(){} Employee::~Employee() {} Employee emp[20], tempemp[20], sortemp[20], sortemp1[20],temp[20]; int num, i, j,jobcode; bool sorted;

void Employee::login() { system("COLOR 0A"); string pd, password = "1"; string un, username = "q"; bool loginSuccess = false; int att = 0; while(att<3) { cout << "Username : "; cin >> un; cout << "Password : "; cin >> pd; if (username == un && password == pd) { cout << " -------------------- "; cout << "Login Successful" << endl; cout << "-------------------- "; loginSuccess = true; break; } else { cout << " ------------------------ "; cout << "Invalid ID or PASSWORD !" << endl; cout <<" Please try again you have maximum 3 attempt only " << endl; att++; } if (att == 3) { cout << "You have reach the limit attempt and this program will exit " << endl; exit(-99); } } system("pause"); } void Employee::menu() { system("cls"); cout << " "; cout<<(" ***** Employees Management System 1.0 ***** ")<Built The Employee Table "; cout << " "; cout << " \t\t Press 2---->Display The Employee Table "; cout << " "; cout << " \t\t Press 3---->Add New Entry "; cout << " "; cout << " \t\t Press 4---->Delete An Entry "; cout << " "; cout << " \t\t Press 5---->Edit An Entry "; cout << " "; cout << " \t\t Press 6---->Search Job Code "; cout << " "; cout << " \t\t Press 7---->Sort The Table "; cout << " "; cout << " \t\t Press 8---------->Quit Program "; cout << " "; }

void Employee::build() { cout<< " Build The Table"< 20" << endl; cout << "How many do you want -----> "; cin >> num; cout << "Enter The Following Items : " << endl; for (int i = 0; i <= num-1; i++) { cout << "Name "; cin >> emp[i].name; cout << "Code "; cin >> emp[i].code; cout << "Designation "; cin >> emp[i].designation; cout << "Years of Experience "; cin >> emp[i].exp; cout << "Age "; cin >> emp[i].age; } cout << " Going to main menu"<

void Employee::display() { system("cls"); cout<<" ********Display The Table********"<

void Employee::add() { system("cls"); int i = num; num += 1; cout<<("Insert New Record")<> emp[i].name; cout << "Code "; cin >> emp[i].code; cout << "Designation "; cin >> emp[i].designation; cout << "Years of Experience "; cin >> emp[i].exp; cout << "Age "; cin >> emp[i].age; cout << endl; cout << "Going to main menu" << endl<> code; int i; for (i = 0; i <= num - 1; i++) { if (emp[i].code == code) { check = i; } } for (i = 0; i <= num - 1; i++) { if (i == check) { continue; } else { if (i>check) { tempemp[i - 1] = emp[i]; } else { tempemp[i] = emp[i]; } } } num--; for (i = 0; i <= num - 1; i++) { emp[i] = tempemp[i]; } cout << " Press Any Key To Go Back" << endl<> jobcode; for (int i = 0; i <= num - 1; i++) { if (emp[i].code == jobcode) { cout << " Name Code Designation Years(EXP) Age " << endl; cout << " -----------------------------------------------------" << endl; cout << setw(7) << emp[i].name; cout << setw(9) << emp[i].code; cout << setw(12) << emp[i].designation; cout << setw(15) << emp[i].exp; cout << setw(14) << emp[i].age; cout << endl; cout << "Enter New Job Code-----> "; cin >> emp[i].code; } } cout << "Press Any Key To Go Back" << endl << endl; system("pause"); }

void Employee::search() { system("cls"); cout<<("Welcome To Search Of Employee Database ")<> jobcode; for (int i = 0; i <= num - 1; i++) { if (emp[i].code == jobcode) { cout << " Name Code Designation Years(EXP) Age "<

sortemp1[i] = sortemp1[j];

sortemp1[j] = temp[i]; } } } for (i = 0; i <= num - 1; i++) { cout << " Name Code Designation Years(EXP) Age "<

*****MainEmployee.cpp****

#include using namespace std; #include "Employee.h"

void main() { int option; Employee m; m.login(); m.menu(); cout << " \t\t Select Your Option Please ====> "; cin >> option; while (option != 8) { switch (option) { case 1: m.build(); break;

case 2: m.display(); break; case 3: m.add(); break;

case 4: m.deletes(); break;

case 5: m.edit(); break;

case 6: m.search(); break;

case 7: m.sort(); break;

case 8: exit(0); cout << "invalid selection" << endl; } m.menu(); cout << " \t\t Select Your Option Please ====> "; cin >> option; } return; }

******Employee.h***

#ifndef EMPLOYEE_H #define EMPLOYEE_H const int max = 20;

class Employee { public: Employee(); ~Employee(); void login(); void menu(); void build(); void display(); void add(); void deletes(); void edit(); void search(); void sort(); private: char name[20]; long int code; char designation[20]; int exp; int age; int num; }; #endif

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!