Receiving error when compiling

invalid operands of types double[100]' anddouble[100]' to binary `operator*'

The code looks like as follows. Trying to submit for homework this evening, and I'm stuck!!!

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[])
{
 double employeeSalaryRaises[100];
 double employeeSalaries[100];
 string employeeFirstNames[100];
 string employeeLastNames[100];
 int counter;

   double salary;
   string firstName;
//   string lastName;
   double raise;
   int newSalary;
   double employees;

   ifstream  inFile;
   ofstream outFile;
   inFile.open("Ch5_Ex2Data.txt");
   outFile.open("Ch5_Ex2Output.txt");
//   int i;
   counter = 0;


//check to ensure there is a valid input file
if (!inFile)
{
                  cout << "Input file failed." << endl;
                  cout << "Program Terminates!!!" << endl;
                  cout << " " << endl;

                  system ("PAUSE");
                  return 1;
}


while (!inFile.eof())
{
   inFile >> employeeLastNames[counter] >> employeeFirstNames[counter] >> employeeSalaries[counter] >>  employeeSalaryRaises[counter];

   counter = counter + 1;
   newSalary = employeeSalaries * employeeSalaryRaises /100

}

double temp;
int index;
int i;


  for(i=0; i< counter; i++)
  {
           for (index =0; index < counter -i -1; index++)
           {
               if ( employeeSalaries [index] < employeeSalaries [index + 1])
               {
                    temp = employeeSalaries[index];
                    employeeSalaries[index] = employeeSalaries[index +1];
                    employeeSalaries[index +1] = temp;
                    }
                    }
}

string lastName;
for (i=0; i<counter; i++)
{
    employees = employeeSalaries[i];


         outFile << fixed << showpoint; 
         outFile << setprecision(2);                    
         outFile << "Record " << i << ":" << employees << " " << endl;

         cout << fixed << showpoint;
         cout << setprecision (2);           
         cout << "Record " << i << ":" << employees << " " << endl;

  }  
    system("PAUSE");
    return EXIT_SUCCESS;
}

Thanks. How should I change it?

Any idea how I can fix this?

Your trying to multiply 2 double arrays, instead of the values inside the arrays

Thanks, I follow that and can see it's wrong, but I'm not sure where to go from there? I checked out the document you posted, and still am confused how to fix.

Sorry man, but I'm no whizz at c++ yet. Only learning like you :D.
Only thing I can suggest is using that same counter variable.

inFile >> employeeLastNames[counter] >> employeeFirstNames[counter] >> employeeSalaries[counter] >> employeeSalaryRaises[counter];

newSalary = employeeSalaries[counter] * employeeSalaryRaises[counter] /100 //Whats the /100 for?
counter = counter + 1;

This is only a suggestion. But looking at this, your newSalary variable wouldn't do anything except hold the value until it looped again, then it would change, meaning you need to store it someway.(e.g. an int array, then just add newSalary to the array before it loops again)

Thanks a lot for your help. I got everything working now. Really appreciate your assistance....

Thanks a lot for your help. I got everything working now. Really appreciate your assistance....

Incase you didn't realise, you can shorten your counter=counter+1 expression, to just counter++. Also don't forget to mark solved threads.

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.