Hi I have this error..can someone Please help me to solve it??
The coding works on my friend's pc though...
#include <iostream.h>
#include <cstring.h>
struct program
{
int employee_id;
int salary;
int eval;
string name;
};
// Use constants for Arrays Sizes like below.
const int NUMBER_OF_EMPLOYEES = 2;
const int NUMBER_OF_PERFORMANCE_LEVELS = 4;
main()
{
int i;
float sal[NUMBER_OF_EMPLOYEES];
float new_salary(float,int);
//float sum_perform[NUMBER_OF_PERFORMANCE_LEVELS]= { 0, 0, 0, 0 };
int TotalSalary[ NUMBER_OF_PERFORMANCE_LEVELS ] = { 0, 0, 0, 0 };
int Count[ NUMBER_OF_PERFORMANCE_LEVELS ] = { 0, 0, 0, 0 };
float Highest;
program employee[ NUMBER_OF_EMPLOYEES ];
for (i = 0; i<NUMBER_OF_EMPLOYEES;i++)
{
cout<<"Enter your employee name: ";
cin>>employee[i].name;
cout<<"Enter your employee identification number: ";
cin>>employee[i].employee_id;
while( employee[i].employee_id > 9999)
{
cout<<"ERROR!! Please enter ID again\n";
cout<<"Enter your employee identification number: ";
cin>>employee[i].employee_id;
}
cout<<"Enter current annual salary: ";
cin>>employee[i].salary;
cout<<"Enter result of supervisor evaluation: \n"
<<" 1. Superior Performance.\n"
<<" 2. Above Average.\n"
<<" 3. Average.\n"
<<" 4. Below Average.\n"
<<" Enter rating between 1 - 4 : ";
cin>>employee[i].eval;
while(employee[i].eval<1 || employee[i].eval>4)
{
cout<<"ERROR!! Please enter result of supervisor evaluation again";
cout<<"Enter result of supervisor evaluation: \n"
<<" 1. Superior Performance.\n"
<<" 2. Above Average.\n"
<<" 3. Average.\n"
<<" 4. Below Average.\n"
<<" Enter rating between 1 - 4 : ";
cin>>employee[i].eval;
}
sal[i] = new_salary(employee[i].salary, employee[i].eval);
TotalSalary[employee[i].eval - 1 ] += sal[i] ; // The Total Salary for a Performance Level
Count[ employee[i].eval - 1 ] += 1; // The Number of Workers at a Performance Level
}
cout<<"\n\n";
cout<<"\t-----------------------------------------------------\n";
cout<<"\t **************************************************\n";
cout<<"\t* RRRRRRR EEEEE SSSSSS UU UU LL TTTTTTTT *\n";
cout<<"\t* RR RR EE SS UU UU LL TT *\n";
cout<<"\t* RRRRRRR EEEEE SSSSSS UU UU LL TT *\n";
cout<<"\t* RR R EE SS UU UU LL TT *\n";
cout<<"\t* RR R EEEEE SSSSSS UUUUUU LLLLLL TT *\n";
cout<<"\t **************************************************\n";
for (i = 0; i<NUMBER_OF_EMPLOYEES;i++)
{
cout<<"\n\n";
cout<<"\t"<<"Your employee name is: ";
cout<<employee[i].name<<endl;
cout<<"\t"<<"Your employee identification number is: ";
if(employee[i].employee_id < 10)
cout<<"000"<<employee[i].employee_id<<endl;
else if (employee[i].employee_id < 100)
cout<<"00"<<employee[i].employee_id<<endl;
else if(employee[i].employee_id < 1000)
cout<<"0"<<employee[i].employee_id<<endl;
else
cout<<employee[i].employee_id<<endl;
cout<<"\t"<<"Your current annual salary is: RM";
cout<<employee[i].salary<<endl;
cout<<"\t"<<"Result of supervisor evaluation: ";
cout<<employee[i].eval<<endl;
cout<<"\t"<<"Your new employee salary is: RM";
cout<<sal[i]<<endl;
cout<<"\n\n";
}
// Output the Average Salaries for Performance Levels
if ( Count[ 0 ] != 0 )
{
cout<<"\tSup Level Salaries Average = "<<TotalSalary[0] / Count[0] <<endl;
}
if ( Count[ 1 ] != 0 )
{
cout<<"\tAbove-Avg Level Salaries Average = "<<TotalSalary[1] / Count[1] <<endl;
}
if ( Count[ 2 ] != 0 )
{
cout<<"\tAvg-Level Salaries Average = "<<TotalSalary[2] / Count[2] << endl;
}
if ( Count[ 3 ] != 0 )
{
cout<<"\tBelow-Avg Level Salaries Average = "<<TotalSalary[3] / Count[3] <<endl;
}
Highest = sal[0];
for(i=0;i<NUMBER_OF_EMPLOYEES;i++)
{
int x;
if(sal[i]>=Highest)
x = i;
}
cout<<employee[i].name;
return 0;
}
float new_salary(float x, int y)
{
float n_salary;
if(y == 1)
n_salary = (0.04 *x) + x;
else if(y == 2)
n_salary = (0.03*x) + x;
else if(y == 3)
n_salary = (0.02*x) + x;
else if(y == 4)
n_salary = x;
return n_salary;
}
here is the code..