For my assignment, I need to add the job name, actor name and salary for a casting agency. I guess the multiple array here would be the job name and actor name. I'm stuck at this part: talent[jobname][talentname] = ???. How do I save this data as well as salary into this array?
Motobus, yeah I realized I was overthinking it quite a bit, haha. Thanks for putting me back on track and saving me a headache!
another question now though, I'm trying to find the average of salaries of people with the same job name, however, I'm not sure how to set the denominator up. When I use i, the average just displays as the total. How can I fix this?
void search(string jobName[], string talentName[], double salary[], int count)
{
// Get User Inputs
string jobname;
cout << "Enter job name: ";
cin >> jobname;
// Declaration of Variables
double total = 0;
double high = -9999;
double low = 9999;
double average = 0;
bool found = false;
for (int i=0; i < count; i++)
{
if (jobName[i] == jobname)
{
cout << talentName[i] << " paid $" << salary[i] << endl;
found = true;
total += salary[i]; // sum of all salaries with jobName[i]
average = total/i; // average of all salaries with jobName[i]
if (high < salary[i])
{
high = salary[i]; // high of all salaries with jobName[i]
}
if (low > salary[i])
{
low = salary[i]; // low of all salaries with jobName[i]
}
}
}
Just make a separate counter variable. Each time to find the jobName you are searching for increment it then use that to divide into your total to get your average.