// Example 9.4. Test program for SalaryInfo #include #include #include "money.h" int main(void) { void SalaryInfo(money&, int&); // prototype money total; // total salary int num; // number of salaries SalaryInfo(total, num); cout << "Total of salaries = "; total.display(); cout << endl; cout << "Number of salaries = " << num << endl; return 0; } // // Function to determine the total amount of money spent on // salaries and the number of salaries in a file // Pre: "EX0904.dat" is a disk file of employee salaries. // Post: SalaryTotal is the money salary total. // NumSalaries is the integer number of salaries. // void SalaryInfo(money& SalaryTotal, int& NumSalaries) { double salary; // salary from the file money SalaryObj; // salary object with value salary ifstream SalaryFile("EX0904.dat"); assert(SalaryFile); NumSalaries = 0; SalaryTotal.AssignMoney(0.0); while (SalaryFile >> salary) { SalaryObj.AssignMoney(salary); SalaryTotal.AddTo(SalaryObj); NumSalaries++; } SalaryFile.close(); }