Write a C++ program to implement employee directory, which will let the organization to perform the following functions:

1) Insert the record of new employee
2) Delete the record of an existing employee
3) Find the record of an existing employee
4) Display Report

Following information of each employee must be stored

Employee ID: an integer value to store the unique id for each employee
Employee Name: the name of each employee.
Employee Address: Address of each employee
Employee Salary: a float value to store salary of each employee.

Recommended Answers

All 12 Replies

I don't know what the question is, I'm guessing you want someone to create the program for you.. If this is the case, you'll find it pretty hard to find someone who actually will. But some advice:

1) Insert the record of new employee
2) Delete the record of an existing employee
3) Find the record of an existing employee
4) Display Report

4 functions that communicate with each other. I don't think it would be over complicated at all, doesn't look like you have to use any OO features.

Make an effort with the code, someone will help you.

so no one has solved it still............

so no one has solved it still............

If anyone has bothered, they will not post the code. It is counterproductive and against Daniweb's rules to help people cheat on their homework.

i did a code but i cant compile it plz any one help to debug my code and make it run.

#include <iostream>
using namespace std;

struct node
  {  int empID;
char *empName;
char *empAddress;
float empSalary;
node * pNext;

     node *nxt;// Pointer to next node
  };

node *start_ptr = NULL;
node *current;       // Used to move along the list
int option = 0;

void add_node_at_end()
  {  node *temp, *temp2;   // Temporary pointers

     // Reserve space for new node and fill it with data
     temp = new node;
     cout << "Please Enter EmpID ";
     cin >> temp->empID;
     cout << "Please Enter EmpName: ";
     cin >> temp->empName;
     cout << "Please Enter EmpAddress:  ";
     cin >> temp->empAddress;
     cout << "Please Enter Emp Salary:   ";
     cin >> temp->empSalary;
     temp->nxt = NULL;

     // Set up link to this node
     if (start_ptr == NULL)
       { start_ptr = temp;
     current = start_ptr;
       }
     else
       { temp2 = start_ptr;
         // We know this is not NULL - list not empty!
         while (temp2->nxt != NULL)
           {  temp2 = temp2->nxt;
              // Move to next link in chain
           }
         temp2->nxt = temp;
       }
  }

void display_list()
  {  node *temp;
     temp = start_ptr;
     cout << endl;
     if (temp == NULL)
       cout << "The list is empty!" << endl;
     else
       { while (temp != NULL)
       {  // Display details for what temp points to
              cout << "Enter EmpName : " << temp->empName << " ";
              cout << "Enter EmpID : " << temp->empID << " ";
          cout << "Enter EmpAddress: " << temp->empAddress;
          cout << "Enter Emp Salary: " << temp->empSalary;
          if (temp == current)
        cout << " <-- Current node";
              cout << endl;
          temp = temp->nxt;

       }
     cout << "End of list!" << endl;
       }
  }

void delete_Record()
   { node *temp;
     temp = start_ptr;
     start_ptr = start_ptr->nxt;
     delete temp;
   }



void main()
  {  start_ptr = NULL;
     do
    {
      display_list();
      cout << endl;
      cout << "Please select an option : " << endl;
      cout << "0. Exit the program." << endl;
      cout << "1. Insert New employee," << endl;
      cout << "2. Delete a record from the list." << endl;



          cout << endl << " >> ";
      cin >> option;

      switch (option);
        {
          case 1 : Insert New employee(); break;
          case 2 : delete_Record(); break;
          case 3 : Display Report(); break;       


        }
    }
     while (option != 0);
  }

Hey, first off:
1. Your code isn't in code tags.
2. Your code layout is... mediocre
3. Why are you voiding main?
4. You haven't said what the error(s) are.

Hey, first off:
1. Your code isn't in code tags. is it u said to put

and

2. Your code layout is... mediocre i write it in devc++
3. Why are you voiding main?
4. You haven't said what the error(s) are.

it is compiling.gives error in lines.and my switch is also not working

it is compiling giving error in switch statement and in function calling

The reason your switch statement isn't working is because the syntax is incorrect. I'll describe your problem(s) the best way I can:

switch (option); // Shouldn't have the semi-colon, delete it
{
case 1: Insert New employee(); 
break;
case 2 : delete_Record(); 
break;
case 3 : Display Report(); 
break;	
default: cout << "Unknown option"; // You need to have a default statement.
}

my code is not compiling and switch statement is also not working.

I'm not allowed to give any code away.. What are the errors?

thanks a lot sir; i did the correction in this now it is saying th8 main must return int. and giving error in function calling.can u plz help in it

int to return value:

int main()
{

// code 
// code
return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.