14 Replies - 1099 Views - Last Post: 12 May 2010 - 03:10 PM Rate Topic: -----

#1 fraandres  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 31-March 09

Array Employees

Posted 08 May 2010 - 12:15 PM

I'm just getting a bunch of error codes on this program I'm not too sure if I have the logic correctly of the Arrays Just if anyone can help me make sure that Im passing the arrays correctly and also calling them I will really appreaciated.

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


bool tryAgain (char[],int);
bool isValidStatus(char[],int);
bool isValidID (int[],int);

const double hour=18.75;
const double commission=1000;

int main()

{
const int getEmployeeData =4;
int emp[getEmployeeData];
char id [getEmployeeData];
float status [getEmployeeData];
float calculateGrossPay [id,status];
void displayEmployeeInfo [emp,id,status];
int index;
bool result;
float total;





do{


result = getEmployeeData(emp,id,status)//is this how I call the array?
if (result==true );
{	
total= calculateGrossPay(status,empdata);//is this how I call the array?
displayEmployeeInfo(employeeid,status,empdata);//is this how I call the array?

}
}while (result==true);

return 0;

} 
int getEmployeeData (int str[],int index) // Do I need to send the size too? (char str[], char size)?? 
{

	index=0;
	for(index=0; index<getEmployeeData; index++)
	{
		cout<<"Enter employee ID ====> "<<(index + 1);
		cin>>emp[index];
		result=isValidID(emp[index]);
			if (result==false)
				return false;
		
	}
}
	
	}
	
	bool result=false;

	do
	{
	for(int index=0; index< getEmployeeData; index++)
	{
	cout<<"Enter payroll status (s/h/c)====>";
	cin>>id[index];
	}
	 result= isValidStatus(id[index]); 

	  if(!result)
	  {
	 

	 
                         
                 
                cout<<"Invalid payroll status. \n Try again? Q or q to quit, any other key to continue:"; 
                cin>>id[index]; 
		if (!tryAgain (id[index]))
	  return false;
	  
	  }
	  
	  }while(!result);
	
	
 
	if (y =='s' || y=='S')
	{
		cout<<"Enter monthly salary ====>";
		cin>>id[index];
	}
	else if (y == 'h' || y== 'H')
	{
		cout<<"Enter number of hours worked this month ====>";
		cin>>id[index];
	}
	else if( y == 'c' || y == 'C')
	{
		cout<<"Enter total sales for this month ====> ";
		cin >> id[index];
		//result= tryAgain(z);
	}
		//}while (result == true);
	
	return true;

	

}
float calculateGrossPay (char w[], double p[])// is this correct? or any syntax error?
{
if (w =='s' || w=='S')
	{
p=p;
}
else if (w == 'h' || w== 'H')
{
	p=hour*p;

}



else if( w == 'c' || w == 'C')
{
p=p*0.06 + commission;

}

return p;

}




void displayEmployeeInfo (int id [], char sta[], double data[],char size)// is this correct, I send the size of the array?

{
	
	for(index=0; index<getEmployeeData; index++)
	{
cout<<"Employee ID:"<<id[index]<<endl;
cout<<"Payroll Status:"<<sta[index]<<endl;
cout << "Total: "<<data[index]<<endl;
	}

	
	}
bool tryAgain (char input[], int index)

{	
	
	
		if (yy == 'q' || yy == 'Q')
	
	
		return false;
		
		else 

			return true;
		
	
		
}
bool isValidStatus (char input[],int index) //I send the size also is this correct?

{
	if(xx!='c' && xx!= 'C' && xx!='h' && xx!= 'H' && xx!='S' && xx!='s') //&& xx != 'q' && xx!= 'Q') 
                      

		return false;
	
	else 

                 
 
           return true; 
		
}
bool isValidID (char input[],char size) //here Im sure we dont need the size?
{
int str;
str=strlen(input)
if (str<100 || str >999)
{
return false;
}
else
{
if (isDigit(input[str])==false)
return false;
}
return true;
}

	


Is This A Good Question/Topic? 0
  • +

Replies To: Array Employees

#2 apw5020  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 666
  • Joined: 26-March 09

Re: Array Employees

Posted 08 May 2010 - 12:50 PM

Why do you have a variable AND a function named getEmployeeData? That makes no sense.

You're missing a few function prototypes, too.

What errors are you getting?

This post has been edited by apw5020: 08 May 2010 - 12:51 PM

Was This Post Helpful? 0
  • +
  • -

#3 fraandres  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 31-March 09

Re: Array Employees

Posted 08 May 2010 - 01:05 PM

View Postapw5020, on 08 May 2010 - 11:50 AM, said:

Why do you have a variable AND a function named getEmployeeData? That makes no sense.

You're missing a few function prototypes, too.

What errors are you getting?



I'm sorry is this what you mean:


result = getEmployeeData(emp,id,status)//this is a function so I should call it differently?

//I thought I was calling the array here, maybe Im wrong





Was This Post Helpful? 0
  • +
  • -

#4 apw5020  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 666
  • Joined: 26-March 09

Re: Array Employees

Posted 08 May 2010 - 01:27 PM

View Postfraandres, on 08 May 2010 - 04:05 PM, said:

View Postapw5020, on 08 May 2010 - 11:50 AM, said:

Why do you have a variable AND a function named getEmployeeData? That makes no sense.

You're missing a few function prototypes, too.

What errors are you getting?



I'm sorry is this what you mean:


result = getEmployeeData(emp,id,status)//this is a function so I should call it differently?

//I thought I was calling the array here, maybe Im wrong






That part is right, but you have this const int getEmployeeData =4; which is the same name as your function. If you are calling the function, you need to provide it with arguments. If not, you should give the variable a different name.

Also, why are you putting the arguments to your functions in square brackets?
float calculateGrossPay [id,status]; 
void displayEmployeeInfo [emp,id,status]; 



The function should be called like this:
float retVal = calculateGrossPay(id,status); 
displayEmployeeInfo(emp,id,status); // more args ? 


This post has been edited by apw5020: 08 May 2010 - 01:36 PM

Was This Post Helpful? 0
  • +
  • -

#5 fraandres  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 31-March 09

Re: Array Employees

Posted 09 May 2010 - 02:11 PM

I'm Getting a lot of error codes this is my errors.
Im expecting all the answers for the erros but at least and idea of what Im doing wrong thanks!

syntax error : 'float' should be preceded by ';'
: error C2144: syntax error : 'int' should be preceded by ';'
error C2144: syntax error : 'double' should be preceded by ';'
error C2270: 'getEmployeeData' : modifiers not allowed on nonmember functions
error C2078: too many initializers
error C2182: 'displayEmployeeInfo' : illegal use of type 'void'
error C2078: too many initializers
warning C4244: 'initializing' : conversion from 'float' to 'int', possible loss of data
error C2664: 'getEmployeeData' : cannot convert parameter 3 from 'float' to 'int []'
error C2143: syntax error : missing ';' before 'if'
warning C4390: ';' : empty controlled statement found; is this the intent?
: error C2065: 'empdata' : undeclared identifier
error C2065: 'employeeid' : undeclared identifier
: error C2065: 'empdata' : undeclared identifier
error C2065: 'EmployeeData' : undeclared identifier
error C2065: 'emp' : undeclared identifier
error C2065: 'result' : undeclared identifier
error C2065: 'emp' : undeclared identifier
error C2660: 'isValidID' : function does not take 1 arguments
error C2065: 'result' : undeclared identifier
error C2059: syntax error : 'do'
error C2143: syntax error : missing ';' before '{'
error C2447: '{' : missing function header (old-style formal list?)
: error C2059: syntax error : 'while'
error C2059: syntax error : 'if'
error C2143: syntax error : missing ';' before '{'
error C2447: '{' : missing function header (old-style formal list?)
error C2059: syntax error : 'else'
: error C2143: syntax error : missing ';' before '{'
error C2447: '{' : missing function header (old-style formal list?)
error C2059: syntax error : 'else'
error C2143: syntax error : missing ';' before '{'
error C2447: '{' : missing function header (old-style formal list?)
error C2059: syntax error : 'return'
error C2059: syntax error : '}'
error C2143: syntax error : missing ';' before '}'
error C2059: syntax error : '}': error C2143: syntax error : missing ';' before '{'
error C2447: '{' : missing function header (old-style formal list?)
error C2065: 'EmployeeData' : undeclared identifier
error C2065: 'yy' : undeclared identifier
error C2065: 'yy' : undeclared identifier
error C2065: 'xx' : undeclared identifier error C2065: 'xx' : undeclared identifier
error C2065: 'xx' : undeclared identifier
error C2065: 'xx' : undeclared identifier
error C2065: 'xx' : undeclared identifier
error C2065: 'xx' : undeclared identifier




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


bool tryAgain (char[],int);
bool isValidStatus(char[],int);
bool isValidID (int[],int);
void displayEmployeeInfo(int[],char[],int[],int)
float calculateGrossPay(char[],int[], int)
int getEmployeeData(int[],char[],int[],int)
const double hour=18.75;
const double commission=1000;

int main()

{
const int EmployeeData =4;
int emp[EmployeeData];
char id [EmployeeData];
float status (EmployeeData);
float calculateGrossPay (id,status);
void displayEmployeeInfo (emp,id,status);
//int getEmployeeData(emp,id,status)
int index;
bool result;
float total;





do{


result = getEmployeeData(emp,id,status, EmployeeData)//is this how I call the array?
if (result==true );
{	
float total= calculateGrossPay(status,empdata,getEmployeeData);//is this how I call the array?
displayEmployeeInfo(employeeid,status,empdata,getEmployeeData);//is this how I call the array?

}
}while (result==true);

return 0;

} 
int getEmployeeData (int str[],int index) // Do I need to send the size too? (char str[], char size)?? 
{

	index=0;
	for(index=0; index<EmployeeData; index++)
	{
		cout<<"Enter employee ID ====> "<<(index + 1);
		cin>>emp[index];
		result=isValidID(emp[index]);
			if (result==false)
				return false;
		
	}
}
	
	
	
	bool result=false;

	do
	{
	for(int index=0; index< EmployeeData; index++)
	{
	cout<<"Enter payroll status (s/h/c)====>";
	cin>>id[index];
	}
	 result= isValidStatus(id[index]); 

	  if(!result)
	  {
	 

	 
                         
                 
                cout<<"Invalid payroll status. \n Try again? Q or q to quit, any other key to continue:"; 
                cin>>id[index]; 
		if (!tryAgain (id[index]))
	  return false;
	  
	  }
	  
	  }while(!result);
	
	
 
	if (y =='s' || y=='S')
	{
		cout<<"Enter monthly salary ====>";
		cin>>id[index];
	}
	else if (y == 'h' || y== 'H')
	{
		cout<<"Enter number of hours worked this month ====>";
		cin>>id[index];
	}
	else if( y == 'c' || y == 'C')
	{
		cout<<"Enter total sales for this month ====> ";
		cin >> id[index];
		//result= tryAgain(z);
	}
		//}while (result == true);
	
	return true;

	

}
float calculateGrossPay (char w[], int p[], int)// is this correct? or any syntax error?
{
if (w =='s' || w=='S')
	{
p=p;
}
else if (w == 'h' || w== 'H')
{
	p=hour*p;

}



else if( w == 'c' || w == 'C')
{
p=p*0.06 + commission;

}

return p;

}




void displayEmployeeInfo (int id [], char sta[], int data[],char size)// is this correct, I send the size of the array?

{
	int index=0;
	for(index=0; index<EmployeeData; index++)
	{
cout<<"Employee ID:"<<id[index]<<endl;
cout<<"Payroll Status:"<<sta[index]<<endl;
cout << "Total: "<<data[index]<<endl;
	}

	
	}
bool tryAgain (char input[], int index)

{	
	
	
		if (yy == 'q' || yy == 'Q')
	
	
		return false;
		
		else 

			return true;
		
	
		
}
bool isValidStatus (char input[],int index) //I send the size also is this correct?

{
	if(xx!='c' && xx!= 'C' && xx!='h' && xx!= 'H' && xx!='S' && xx!='s') //&& xx != 'q' && xx!= 'Q') 
                      

		return false;
	
	else 

                 
 
           return true; 
		
}
bool isValidID (char input) //here Im sure we dont need the size?
{
int str;
str=strlen(input)
if (str<100 || str >999)
{
return false;
}
else
{
if (isDigit(input[str])==false)
return false;
}
return true;
}


Was This Post Helpful? 0
  • +
  • -

#6 japanir  Icon User is offline

  • jaVanir
  • member icon

Reputation: 1010
  • View blog
  • Posts: 3,025
  • Joined: 20-August 09

Re: Array Employees

Posted 09 May 2010 - 02:18 PM

you are missing a lot of semicolons in the end of the function prototypes:
bool tryAgain (char[],int); 
bool isValidStatus(char[],int); 
bool isValidID (int[],int); 
void displayEmployeeInfo(int[],char[],int[],int)//<<";" missing here
float calculateGrossPay(char[],int[], int) //<<";" missing here
int getEmployeeData(int[],char[],int[],int)//<<";" missing here


then, you have a lot of variables that you use but never declared on... (like 'xx', 'yy', etc)
check the error messages they are very straightforward

This post has been edited by japanir: 09 May 2010 - 02:19 PM

Was This Post Helpful? 0
  • +
  • -

#7 fraandres  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 31-March 09

Re: Array Employees

Posted 09 May 2010 - 02:51 PM

This is what really is confusing me and Im sorry to ask again


thi is my prototype

int getEmployeeData(int[],char[],int[],int); //because im calling :


result = getEmployeeData(emp,id,status,EmployeeData); //I what sure this is correct and:

int getEmployeeData(int str[],int index)//this is the header 
//do i have to like this(int x[],int y[],int z,int index)??

Was This Post Helpful? 0
  • +
  • -

#8 japanir  Icon User is offline

  • jaVanir
  • member icon

Reputation: 1010
  • View blog
  • Posts: 3,025
  • Joined: 20-August 09

Re: Array Employees

Posted 09 May 2010 - 03:09 PM

when declaring a function prototype, you end the declaration with ";".
like:
void func(int, int[]);


when you call a function, and supply parameters, you must make sure you pass the current data types.
so in my example above, if i call it as:
func(a, arr);

I must make sure that a is an int value, and arr is an array of int values.
the names of the parameters really doesn't matter(as long as you name them according to the rules!)
Was This Post Helpful? 0
  • +
  • -

#9 fraandres  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 31-March 09

Re: Array Employees

Posted 09 May 2010 - 06:37 PM

I have lower a lot of the errors I was having but still have some and I have a couple of issues I made comments to the code already thanks for the help.


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


bool tryAgain (char[]);
bool isValidStatus(char[],int);
bool isValidID (char[]);
int getEmployeeData(int[],int[],int[],int);
float calculateGrossPay(int[],int[], int);
void displayEmployeeInfo(int[],int[],int[],int);
const double hour=18.75;
const double commission=1000;

int main()

{
const int EmployeeData =4;
int emp[EmployeeData];
int id [EmployeeData];
int status [EmployeeData];
//float calculateGrossPay (status,emp);
//void displayEmployeeInfo (emp,id,status);
//int getEmployeeData(emp,id,status);
int index;
bool result;
float total;





do{


result = getEmployeeData(id,status,emp,EmployeeData); // not sure what is this :  warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
if (result==true );
{	
total= calculateGrossPay(status,emp,EmployeeData);
displayEmployeeInfo(id,status,emp,EmployeeData);

}
}while (result==true);

return 0;

} 
int getEmployeeData (int callId[],char callStatus[],int callEmp[], int size) 
{

	
	for(int index=0; index<size; index++)
	{
		cout<<"Enter employee ID ====> "<<(index + 1);
		cin>>callId[index];  // after this should I return any result becaue I know this is not a bool function so it has to return a value.
		bool result=isValidID(callId[index]); // I have a issue here that if I delete bool it tell's me unreference local variable "Result" and I have a error "isValidID' : cannot convert parameter 1 from 'int' to 'char []'"
			if (result==false)
				return false;
		
	}
}
	
	
	
	bool result=false;

	do  //  error C2059: syntax error : 'do'
	{ // not sure what this means:   error C2447: '{' : missing function header (old-style formal list?)
	for(int index=0; index< size; index++)
	{
	cout<<"Enter payroll status (s/h/c)====>";
	cin>>callStatus[index];
	}
	 result= isValidStatus(callStatus[size]); 

	  if(!result)
	  {
	 

	 
                         
                 
                cout<<"Invalid payroll status. \n Try again? Q or q to quit, any other key to continue:"; 
                cin>>callStatus[index]; 
		if (!tryAgain (callStatus[index]))
	  return false;
	  
	  }
	  
	  }while(!result);
	
	
 
	if (y =='s' || y=='S')//error C2059: syntax error : 'if'
	{
		cout<<"Enter monthly salary ====>";
		cin>>callEmp[index];
	}
	else if (y == 'h' || y== 'H')
	{
		cout<<"Enter number of hours worked this month ====>";
		cin>>callEmp[index];
	}
	else if( y == 'c' || y == 'C')
	{
		cout<<"Enter total sales for this month ====> ";
		cin >> callEmp[index];
		//result= tryAgain(z);
	}
		//}while (result == true);
	
	return result;

	

}
float calculateGrossPay (char w[], int p[], int size)
{ // error C2447: '{' : missing function header (old-style formal list?)
if (w[size] =='s' || w[size]=='S')
	{
p=p;
}
else if (w[size] == 'h' || w[size]== 'H')
{
	p=hour*p;

}



else if( w[size] == 'c' || w[size] == 'C')
{
p=p*0.06 + commission;

}

return p;

}




void displayEmployeeInfo (int id [], char sta[], int data[],int size)

{
	int index=0;
	for(index=0; index<size; index++)
	{
cout<<"Employee ID:"<<id[index]<<endl;
cout<<"Payroll Status:"<<sta[index]<<endl;
cout << "Total: "<<data[index]<<endl;
	}

	
	}
bool tryAgain (char yy[], int size

{	
	
	
		if (yy[size] == 'q' || yy[size] == 'Q')
	
	
		return false;
		
		else 

			return true;
		
	
		
}
bool isValidStatus (char xx[],int size) 

{
	if(xx![size]='c' && xx![size]= 'C' && xx![size]='h' && xx![size]= 'H' && xx![size]='S' && xx![size]='s') //&& xx != 'q' && xx!= 'Q') 
                      

		return false;
	
	else 

                 
 
           return true; 
		
}
bool isValidID (char input) 
{
int str;
for(int index=0; index<size; index++)

str=strlen(input);
if (str<100 || str >999)
{
return false;
}
else
{
if (isdigit(input str)==false)
return false;
}
return true;
}



This post has been edited by fraandres: 09 May 2010 - 06:38 PM

Was This Post Helpful? 0
  • +
  • -

#10 japanir  Icon User is offline

  • jaVanir
  • member icon

Reputation: 1010
  • View blog
  • Posts: 3,025
  • Joined: 20-August 09

Re: Array Employees

Posted 10 May 2010 - 06:18 AM

what are these?
//float calculateGrossPay (status,emp); 
//void displayEmployeeInfo (emp,id,status); 
//int getEmployeeData(emp,id,status);

it seems like a mix of calling a function and declaring a prototype.
these are declared inside the main function, why?
it seems to me that you want to declare the functions, so move these to where all your prototype are located, and change the variables you pass to data types.

isvalid gets a char array, but when you call it here:
bool result=isValidID(callId[index]); 

callId is an int array. (so you get the error that the types don't match).

of course you must keep the declaration that 'result' is a bool. how do you want the compiler to know what is 'result' otherwise?

I would suggest to check your opening and closing braces and see if you have them all in place.
the error messages you get are quite straightforward, try fixing them.

feel free to post again if you still have any problems

This post has been edited by japanir: 10 May 2010 - 06:19 AM

Was This Post Helpful? 0
  • +
  • -

#11 fraandres  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 31-March 09

Re: Array Employees

Posted 11 May 2010 - 02:52 PM

I modify the program I basicalle took out the the validation part because I need at least this program to work but I have a few problems this the program


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


//bool tryAgain (char[]);
//bool isValidStatus(char[],int);
//bool isValidID (int);
int getEmployeeData(int[],int[],int[],int);
float calculateGrossPay(int[],int[], int);
void displayEmployeeInfo(int[],int[],int[],int);
const double hour=18.75;
const double commission=1000;

int main()

{
const int EmployeeData =4;
int emp[EmployeeData];
int id [EmployeeData];
int status [EmployeeData];
//float info [EmployeeData];
//int index;
//bool result;
int result;
float total;








result=getEmployeeData(id,status,emp,EmployeeData); 
total= calculateGrossPay(status,emp,EmployeeData);
displayEmployeeInfo(id,status,emp,EmployeeData);



return 0;
}


int getEmployeeData (int callId[],char callStatus[],int callEmp[], int size) 
{

	
	for(int index=0; index<size; index++)
	{
		cout<<"Enter employee ID ====> "<<(index + 1);
		cin>>callId[index];  
		/*bool result=isValidID(callId[index]); 
			if (result==false)
				return false;*/
		
	}

	
	
	for(int index=0; index< size; index++)
	{
	cout<<"Enter payroll status (s/h/c)====>";
	cin>>callStatus[index];
	
	 

  
	  //int result=0;
 
	if (callStatus[index] =='s' || callStatus[index]=='S')
	{
		cout<<"Enter monthly salary ====>";
		cin>>callEmp[index];
	}
	else if (callStatus[index] == 'h' || callStatus[index]== 'H')
	{
		cout<<"Enter number of hours worked this month ====>";
		cin>>callEmp[index];
	}
	else if(callStatus[index] == 'c' || callStatus[index] == 'C')
	{
		cout<<"Enter total sales for this month ====> ";
		cin >> callEmp[index];
		//result= tryAgain(z);
	}
		//}while (result == true);
	
	return result;
	}

//

}
float calculateGrossPay (char w[], int p[], int size)
{ 
if (w[size] =='s' || w[size]=='S')
	{
p[size]=p[size];
}
else if (w[size] == 'h' || w[size]== 'H')
{
	p[size]=hour*p[size];

}



else if( w[size] == 'c' || w[size] == 'C')
{
p[size]=p[size]*0.06 + commission;

}

return p[size];

}




void displayEmployeeInfo (int id [], char sta[], int data[],int size)

{
	int index=0;
	for(index=0; index<size; index++)
	{
cout<<"Employee ID:"<<id[index]<<endl;
cout<<"Payroll Status:"<<sta[index]<<endl;
cout << "Total: "<<data[index]<<endl;
	}

	
	}
//bool tryAgain (char yy[], int size
//
//{	
//	
//	
//		if (yy[size] == 'q' || yy[size] == 'Q')
//	
//	
//		return false;
//		
//		else 
//
//			return true;
//		
//	
//		
//}
//bool isValidStatus (char xx[],int size) 
//
//{
//	if(xx![size]='c' && xx![size]= 'C' && xx![size]='h' && xx![size]= 'H' && xx![size]='S' && xx![size]='s') //&& xx != 'q' && xx!= 'Q') 
//                      
//
//		return false;
//	
//	else 
//
//                 
// 
//           return true; 
		
//}
//bool isValidID (char input) 
//{
//int str;
//for(int index=0; index<size; index++)
//
//str=strlen(input);
//if (str<100 || str >999)
//{
//return false;
//}
//else
//{
//if (isdigit(input str)==false)
//return false;
//}
//return true;
//}




thi is my progblem here I think :


//int result=0; when i take this out here is the first error: "error C2065: 'result' : undeclared  //identifier but if I put it in then there a long error:

//error LNK2019: unresolved external symbol "void __cdecl displayEmployeeInfo(int * const,int * //const,int //* const,int)" (?displayEmployeeInfo@@YAXQAH00H@Z) referenced in function _main
//1>final 3-2.obj : error LNK2019: unresolved external symbol "float __cdecl calculateGrossPay(int * //const,int * const,int)" (?calculateGrossPay@@YAMQAH0H@Z) referenced in function _main
//1>final 3-2.obj : error LNK2019: unresolved external symbol "int __cdecl getEmployeeData(int * //const,int * const,int * const,int)" (?getEmployeeData@@YAHQAH00H@Z) referenced in function _main
//1>C:\Users\fraandres\Documents\Visual Studio 2008\Projects\Project1\final 3-2\Debug\final 3-2.exe : //fatal error LNK1120: 3 unresolved externals

//not understanding this ...if anyone can explain I could do to the code really appreaciated

 
	if (callStatus[index] =='s' || callStatus[index]=='S')
	{
		cout<<"Enter monthly salary ====>";
		cin>>callEmp[index];
	}
	else if (callStatus[index] == 'h' || callStatus[index]== 'H')
	{
		cout<<"Enter number of hours worked this month ====>";
		cin>>callEmp[index];
	}
	else if(callStatus[index] == 'c' || callStatus[index] == 'C')
	{
		cout<<"Enter total sales for this month ====> ";
		cin >> callEmp[index];
		//result= tryAgain(z);
	}
		//}while (result == true);
	
	return result;
	}



This post has been edited by fraandres: 11 May 2010 - 02:52 PM

Was This Post Helpful? 0
  • +
  • -

#12 fraandres  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 31-March 09

Re: Array Employees

Posted 12 May 2010 - 10:12 AM

I modify the program I basicalle took out the the validation part because I need at least this program to work but I have a few problems this the program


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


//bool tryAgain (char[]);
//bool isValidStatus(char[],int);
//bool isValidID (int);
int getEmployeeData(int[],int[],int[],int);
float calculateGrossPay(int[],int[], int);
void displayEmployeeInfo(int[],int[],int[],int);
const double hour=18.75;
const double commission=1000;

int main()

{
const int EmployeeData =4;
int emp[EmployeeData];
int id [EmployeeData];
int status [EmployeeData];
//float info [EmployeeData];
//int index;
//bool result;
int result;
float total;








result=getEmployeeData(id,status,emp,EmployeeData); 
total= calculateGrossPay(status,emp,EmployeeData);
displayEmployeeInfo(id,status,emp,EmployeeData);



return 0;
}


int getEmployeeData (int callId[],char callStatus[],int callEmp[], int size) 
{

	
	for(int index=0; index<size; index++)
	{
		cout<<"Enter employee ID ====> "<<(index + 1);
		cin>>callId[index];  
		/*bool result=isValidID(callId[index]); 
			if (result==false)
				return false;*/
		
	}

	
	
	for(int index=0; index< size; index++)
	{
	cout<<"Enter payroll status (s/h/c)====>";
	cin>>callStatus[index];
	
	 

  
	  //int result=0;
 
	if (callStatus[index] =='s' || callStatus[index]=='S')
	{
		cout<<"Enter monthly salary ====>";
		cin>>callEmp[index];
	}
	else if (callStatus[index] == 'h' || callStatus[index]== 'H')
	{
		cout<<"Enter number of hours worked this month ====>";
		cin>>callEmp[index];
	}
	else if(callStatus[index] == 'c' || callStatus[index] == 'C')
	{
		cout<<"Enter total sales for this month ====> ";
		cin >> callEmp[index];
		//result= tryAgain(z);
	}
		//}while (result == true);
	
	return result;
	}

//

}
float calculateGrossPay (char w[], int p[], int size)
{ 
if (w[size] =='s' || w[size]=='S')
	{
p[size]=p[size];
}
else if (w[size] == 'h' || w[size]== 'H')
{
	p[size]=hour*p[size];

}



else if( w[size] == 'c' || w[size] == 'C')
{
p[size]=p[size]*0.06 + commission;

}

return p[size];

}




void displayEmployeeInfo (int id [], char sta[], int data[],int size)

{
	int index=0;
	for(index=0; index<size; index++)
	{
cout<<"Employee ID:"<<id[index]<<endl;
cout<<"Payroll Status:"<<sta[index]<<endl;
cout << "Total: "<<data[index]<<endl;
	}

	
	}
//bool tryAgain (char yy[], int size
//
//{	
//	
//	
//		if (yy[size] == 'q' || yy[size] == 'Q')
//	
//	
//		return false;
//		
//		else 
//
//			return true;
//		
//	
//		
//}
//bool isValidStatus (char xx[],int size) 
//
//{
//	if(xx![size]='c' && xx![size]= 'C' && xx![size]='h' && xx![size]= 'H' && xx![size]='S' && xx![size]='s') //&& xx != 'q' && xx!= 'Q') 
//                      
//
//		return false;
//	
//	else 
//
//                 
// 
//           return true; 
		
//}
//bool isValidID (char input) 
//{
//int str;
//for(int index=0; index<size; index++)
//
//str=strlen(input);
//if (str<100 || str >999)
//{
//return false;
//}
//else
//{
//if (isdigit(input str)==false)
//return false;
//}
//return true;
//}




thi is my progblem here I think :


//int result=0; when i take this out here is the first error: "error C2065: 'result' : undeclared  //identifier but if I put it in then there a long error:

//error LNK2019: unresolved external symbol "void __cdecl displayEmployeeInfo(int * const,int * //const,int //* const,int)" (?displayEmployeeInfo@@YAXQAH00H@Z) referenced in function _main
//1>final 3-2.obj : error LNK2019: unresolved external symbol "float __cdecl calculateGrossPay(int * //const,int * const,int)" (?calculateGrossPay@@YAMQAH0H@Z) referenced in function _main
//1>final 3-2.obj : error LNK2019: unresolved external symbol "int __cdecl getEmployeeData(int * //const,int * const,int * const,int)" (?getEmployeeData@@YAHQAH00H@Z) referenced in function _main
//1>C:\Users\fraandres\Documents\Visual Studio 2008\Projects\Project1\final 3-2\Debug\final 3-2.exe : //fatal error LNK1120: 3 unresolved externals

//not understanding this ...if anyone can explain I could do to the code really appreaciated

 
	if (callStatus[index] =='s' || callStatus[index]=='S')
	{
		cout<<"Enter monthly salary ====>";
		cin>>callEmp[index];
	}
	else if (callStatus[index] == 'h' || callStatus[index]== 'H')
	{
		cout<<"Enter number of hours worked this month ====>";
		cin>>callEmp[index];
	}
	else if(callStatus[index] == 'c' || callStatus[index] == 'C')
	{
		cout<<"Enter total sales for this month ====> ";
		cin >> callEmp[index];
		//result= tryAgain(z);
	}
		//}while (result == true);
	
	return result;
	}



Was This Post Helpful? 0
  • +
  • -

#13 japanir  Icon User is offline

  • jaVanir
  • member icon

Reputation: 1010
  • View blog
  • Posts: 3,025
  • Joined: 20-August 09

Re: Array Employees

Posted 12 May 2010 - 01:31 PM

you are declaring different parameters in the prototype, and then in the functions:
look for example at that prototype:
void displayEmployeeInfo(int[],int[],int[],int);

and then the function:
void displayEmployeeInfo (int id [], char sta[], int data[],int size) 

the second parameter is int[] when you declare it, but then you refer to it as a char array.

look at the rest of the functions, you repeat that same mistake.

However, I noticed that when you call the functions in main, you pass 4 int arrays. (and no char array) so think what you really want to do.
Was This Post Helpful? 0
  • +
  • -

#14 fraandres  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 31-March 09

Re: Array Employees

Posted 12 May 2010 - 03:03 PM

Ok thank you I fix the problem I got it working at last ...I just have a quick question:

int getEmployeeData (int callId[],int callStatus[],int callEmp[], int size) 
{

	 
	for(int index=0; index<size; index++)
	{
		cout<<"Enter employee ID  ====> "<<(index + 1)<<":";
		cin>>callId[index];  
				
		cout<<"Enter payroll status (s/h/c)====>"<<(index+1)<<":";;
	cin>>callStatus[index];
	 
	if (callStatus[index] =='s' || callStatus[index]=='S')
	{
		cout<<"Enter monthly salary ====>";
		cin>>callEmp[index];
	}
	else if (callStatus[index] == 'h' || callStatus[index]== 'H')
	{
		cout<<"Enter number of hours worked this month ====>";
		cin>>callEmp[index];
	}
	else  if(callStatus[index] == 'c' || callStatus[index] == 'C')
	{
		cout<<"Enter total sales for this month ====> ";
		cin >> callEmp[index];
			}
	
	return callEmp[index];
	}



is there anything wrong here because I'm getting this as a output
I'm re checking but I just dont see anything wrong

Enter employee ID ====> 1:123
Enter payroll status (s/h/c)====>1:h
Employee ID:123
Payroll Status:-858993460
Total: -858993460
Employee ID:-858993460
Payroll Status:-858993460
Total: -858993460
Employee ID:-858993460
Payroll Status:-858993460
Total: -858993460
Employee ID:-858993460
Payroll Status:-858993460
Total: -858993460
Press any key to continue . . .
Was This Post Helpful? 0
  • +
  • -

#15 japanir  Icon User is offline

  • jaVanir
  • member icon

Reputation: 1010
  • View blog
  • Posts: 3,025
  • Joined: 20-August 09

Re: Array Employees

Posted 12 May 2010 - 03:10 PM

callId[] is declared as int array. but you insert chars and refer to it as char array.
you should declare it as char array.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1