I'm trying to figure out how to do a second part to an assignment that was finished. The idea is that we are supposed to change the functions/prototypes into the format of a structure. I'm having trouble understanding how to create a function that could be used in the main by utilizing this structure format. The problem may be that it is an array which is causing some issue that I can't pin down. If someone could offer some advice I'd be quite happy.
#include <iostream>
#include <string>
#include <iomanip>
usingnamespace std;
struct DIV {
float sale;
string name;
};
// Function Prototypes
void populate_div_sales(DIV [], int); // this function populates an array wit$
int findHighest (DIV [], int); // this function will now return the ind$
void print_result(DIV [], int); // displays result based on the index of highes$
int main() {
int top_div_index = 0; // will be assigned the index of the top divisi$
DIV div_info[4]; // array of type DIV holding the divisions' str$
div_info[0].name = "Northeast";
div_info[1].name = "Southeast";
div_info[2].name = "Northwest";
div_info[3].name = "Southwest";
//keep debug printout
cout << "debug print for array div_info" << endl;
for (int i=0; i<4; i++) {
cout << div_info[i].name << endl;
}
// populate div_sales
populate_div_sales(div_info, 4);
//debug printout
cout << "debug print for array div_info" << endl;
for (int i=0; i<4; i++) {
cout << div_info[i].sale << endl;
}
// find the highest region and save it to this index
// top_div_index = findHighest(div_sales, 4);
return 0;
}
void populate_div_sales(DIV f_div_info[], int f_size) {
// float f_sales[4];
// string f_name[4];
// loop to input quarterly sales
for (int i=0; i<f_size; i++) {
cout << "Enter sales of " << f_div_info[i] << "division: $";
cin >> f_div_info[i];
}
}