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++)
{
cin>>employee[i].name;

cout<<"Enter your employee identification number: ";
cin>>employee[i].employee_id;

while( employee[i].employee_id > 9999)
{
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<<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..

## All 9 Replies

``````#include <iostream>
#include <string>
using namespace std;``````

Er..I'm using turbo C++..not C..so yea it doesn't work

The coding works on my friend's pc though...

Code cannot work on your friends PC if he/she is using TurboC compiler.

Note:Please don't use that compiler again.

It's the same as mine =|

You can't hope to compile a C++ program with Turbo C. In fact, you can't hope to compile some C programs with Turbo C.

Get a better compiler. Top of the list: Dev-C++ (http://www.bloodshed.net).

And if i want back my old compiler? How do i choose it?

How do you run it? Dev-C++ probably installed a shortcut in the start menu. Otherwise, you can run C:\Dev-C++ 4\devcpp or whatever the IDE is called.

If you mean how do you install it, just run the install program.

And if i want back my old compiler? How do i choose it?

You just run it instead. :) Run it however you've always been running it.

Ah okay..i thought that i'm suppose to install dev c++ over my current compiler and overwrite it

i thought that i'm suppose to install dev c++ over my current compiler and overwrite it

Strange Thought :surprised

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.