Emp String String String String: Using Namespace Struct
Emp String String String String: Using Namespace Struct
#include<string>
using namespace std;
struct emp
{
string id;
string name;
int age;
string address;
string role;
float salary;
};
int main()
{
emp arr[1000];
int a, b; string x;
char c;
do
{
cout << "1.Insert an employee into the system.\n";
cout << "2.Search for an employee via their id number.\n";
cout << "3.Edit employee deatails via their id number.\n";
cout << "4.Delete an employee.\n";
cout << "5.Search for all employee with a wage higher than 15000\n";
cout << "Enter the option:";
cin >> a;
if (a == 1)
{
cout << "\nEnter the number of an employee into the system. :";
cin >> b;
else if (a == 2)
{
//cout << "2.Search for an employee via their id number.\n";
cout << "\nEnter the ID of Employee: ";
cin >> x;
for (int k = 0; k < b; k++)
{
if (x == arr[k].id)
{
for (int i = 0; i < b; i++)
{
cout << "\nThe name of Employee:\t\t";
cout << arr[i].name;
}
}
else
{
cout << "\nThis ID does not exit in System:" <<
endl;
}
}
}
else if (a == 3)
{
string J;
//cout << "3.Edit employee deatails via their id number.
}
else if (a == 4)
{
string y;
//cout << "4.Delete an employee.\n"
cout << "\nEnter the Employee ID which you want to delete:\t";
cin >> y;
cout << endl;
for (int i = 0; i < b; i++)
{
if (y == arr[i].id)
{
arr[i].id = "0";
arr[i].name = "0";
arr[i].age = 0;
arr[i].address = "0";
arr[i].role = "0";
arr[i].salary = 0;
}
else
{
cout << "Invalid ID" << endl;
}
}
else if (a == 5)
{
//5.Search for all employee with a wage higher than 15000
cout << "\nAll employee with a wage higher than 15000:" << endl;
for (int i = 0; i < b; i++)
{
if (arr[i].salary > 15000)
{
cout << "\nEnter the ID of Employee:\t";
cout << arr[i].id << endl;
}
else
{
cout << "\nInvalid Input";
}