Server IP : 172.16.15.8 / Your IP : 3.147.27.129 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/pswoodson/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
//***************************************** // An accouting system that keep track of // the expense totals for each employee // at the end of the month. // // // // Written By: Paula S. Woodson // Due Date Friday Dec. 5, 2008 // //****************************************** #include <iostream> #include <iomanip> using namespace std; const int MAXEMPLOYEES = 30; // sets the contents of both arrays to zero void InitializeArrays(float expenses[], int expensecounts[], int numemployees) { for (int i = 0; i < numemployees; i++) { expensecounts[i] = 0; //initialize the expense counts expenses[i] = 0; //intiialize the expenses } } // inputs the "expense slips" from the data file and tallies them into the // arrays void TallyExpenses(float expenses[], int expensecounts[], int numemployees) { float anexpense; // one expense int employeeid; // employee id number cin >> employeeid; while(employeeid != -1) { cin >> anexpense; expensecounts[employeeid] ++; expenses[employeeid] += anexpense; cin >> employeeid; } } // uses the arrays from tallyexpenses to producr an expense summary report void ReportExpenses(float expenses[], int expensecounts[], int numemployees) { float average, // average totalexpense = 0, // total expense minexpense = 1e29; // min expenses int totalnumexpense = 0, // total number expense minid; // min id number cout<< " Expense Summary Report"; cout<< " "; cout<< "\n Employee Id " <<" " << " # of expenses " <<" " << setw(10); cout<< " Expense Total " <<" " << " Average Expense\n"; for(int i = 0; i < numemployees; i++) { cout << setw(8) << i; cout <<" " << setw(8) << expensecounts[i]; cout << fixed << setprecision(2); cout << " $" << setw(8) << expenses[i]; cout << fixed << setprecision(2); average = (expenses[i]/expensecounts[i]); cout << " $"; cout << setw(7); cout << average; cout << "\n\n"; totalnumexpense += expensecounts[i]; totalexpense += expenses[i]; if (expenses[i] < minexpense) { minexpense = expenses[i]; minid = i; } } cout << " Totals"; cout << setw(10) << totalnumexpense; cout << setw(10)<<" " << totalexpense; cout << "\n\n"; cout << "Congratulations to employee number " << minid <<" who had the lowest total"; cout << " expense amount"; cout << "\n"; } int main () { float expenses[MAXEMPLOYEES]; // expense array int expensecounts[MAXEMPLOYEES], // expense counts arrays numemployees; // number of employees cin >> numemployees; // calls the functions from above InitializeArrays(expenses, expensecounts, numemployees); TallyExpenses(expenses, expensecounts, numemployees); ReportExpenses(expenses, expensecounts, numemployees); }