here is my code and problen statement ,i cant compile it plz any one help to debug my code and make it run.plz point out my mistakes.
problem is
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 will 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.
Hint:
Following information of each employee will 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.
You can use the following structure to store the information of a single employee:
Struct Employee {
Int empID;
Char *empName;
Char *empAddress;
Float empSalary;
Employee * pNext;
}Following is the sample interaction:
Welcome to <company name> employee directory:
1) Insert New employee
2) Find employee
3) Delete a record
4) Display Report
5) Exit
Enter your choice: 1
Enter EmpID: 1
Enter EmpName: Ali
Enter EmpAddress: VU, Lahore
Enter Emp Salary: 20000
Record successfully inserted (Press any Key to continue….)
After the user presses any key the screen will be cleared and the menu will be displayed again.
Welcome to <company name> employee directory:
1) Insert New employee
2) Find employee
3) Delete a record
4) Display Report
5) Exit
Enter your choice: 3 (Now user enters 3)
Enter EmpID: 1
Record successfully deleted (Press any key to continue…)
After user presses any key the screen will be cleared and menu will be displayed again.
Welcome to <company name> employee directory:
1) Insert New employee
2) Find employee
3) Delete a record
4) Display Report
5) Exit
Enter your choice: 2 (Now user enters 3)
Enter EmployeID: 1
Employee successfully deleted (Press any key to continue…)
After user presses any key the screen will be cleared and menu will be displayed again
Welcome to <company name> employee directory:
1) Insert New employee
2) Find employee
3) Delete a record
4) Display Report
5) Exit
Enter your choice: 4 (Now user enters 4)
EmpID EmpName EmpAddress EmpSalary
2 Raza VU, Lahore 20000
3 Waseem VU, Lahore 25000
5 Aslam VU, Lahore 20000
Press any key to continue…
After user presses any key the screen will be cleared again and menu will be displayed
Welcome to <company name> employee directory:
6) Insert New employee
7) Find employee
1) Delete a record
2) Display Report
3) Exit
Enter your choice: 5 (Now user enters 5)
Are you sure, you want to exit(y/n) y
Program exited if user presses “y” and menu will be displayed again if user presses “n”
and my code is
Code:
#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;
}
int main()
{ start_ptr = NULL;
int empID;
char *empName;
char *empAddress;
float empSalary;
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:empName;
break;
case 2 : delete_Record();
break;
case 3 : Display Report();
break;
default: cout << "Unknown option program will exit,";
system("PAUSE");
return EXIT_SUCCESS;
}
}
}