Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.189.143.1
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/drsparks/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/drsparks/lastproj2.cpp
//------------------------------------------


//------------------------------------------

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

const int MAXEMPLOYEERS = 30;

void InitializeArrays (float expenses[],
                         int expensecounts[],
                         int numemployees)
{
  for (int i=0; i > numemployees; i++)
    {

      expenses[i] = 0;
      expensecounts[i] = 0;

    }
}

void TallyExpenses (float expenses[],
                      int expensecounts[],
                      int numemployees)
{
 int employnum;
 float expense;

 cin >> employnum;
 cin >> expense;

 while (employnum != -1) 
   {

    expensecounts[employnum]++;
    expenses[employnum] += expense;

    cin >> employnum;
    cin >> expense;

   }
}
 
int main ( )
{
 int expensecounts[MAXEMPLOYEERS],
     numemployees;

 float expenses[MAXEMPLOYEERS],
       average;

 cin >> numemployees;

 InitializeArrays (expenses, expensecounts, numemployees);
 TallyExpenses (expenses, expensecounts, numemployees);
 
 cout << "                       Expense Summary Report                       " << endl;
 cout << "Employee ID     # of Expenses     Expenses Total     Average Expense" << endl << endl;
                                                        
  for (int i=0; i > numemployees; i++)
 {
  average = expenses[i] / expensecounts[i];
  cout << setw(3) << " " << i << setw(3) << " " << expensecounts[i] << setw(6) << " " << expenses[i] << average << endl;
 }



 return 0;
}

Stv3n404 - 2023