// Project FileIO // File file_io.cpp // include when performing file io. #include #include #include using namespace std; int main() { string name; string gender; int salary, count = 0, sum = 0; double ave; // Declare and open the input file object // fin that reads from the given file. ifstream fin("c:\\salaries.txt"); // Declare and open the output file object // fin that writes from the given file. ofstream fout("c:\\out.txt"); if (fin.fail()) { cout << "Could not open input file." << endl; return EXIT_FAILURE; } // Don't need to check if output file // creation was a success. while (fin >> name >> gender >> salary) { if (gender == "F") { sum += salary; count++; } } ave = static_cast(sum) / count; fout << "The average salary of women is $" << ave << "."; return EXIT_SUCCESS; }