Help

Write a program that performs following tasks:
1. Declare three arrays. The sizes of these arrays are all
100. The first array is of integer type. The second and the third
ones are of double type. You may name the arrays as employeeId, hours
and rates respectively.
2. Read the data, total 100 rows, from the file and store them in the three
arrays respectively.
3. Calculate and display the average hours and the average rate.
4. (Bonus)Find and display the employeeID that have earned the most salary.
TotalSalary = TotalHours * rate


This is all I have so far... Please advise???


#include <iostream>
#include <ifstream>

using namespace std;

int main()
{
int employee[100]
double hours [100]
double rate [100]

for (int i=0 ; i< 100 , i++)

cin >> employee [100] >> hours [i] >> rate [i];

return 0;
}

try this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <ifstream>

using namespace std;

int main()
{
int employee[100]
double hours [100]
double rate [100]

for (int i=0 ; i< 100; i++)

cin >> employee [i] >> hours [i] >> rate [i];
//Task3: calculating avg
double sum1=0;
double sum2=0;
for(int i=0; i<100; i++)
{
             sum1 += rate[i];
             sum2 += hours[i];
}
double avgRate = sum1/100;
double avgHours = sum2/100;
cout<< "avg Rate is " << avgRate << endl;
cout << " avg hours is " << avgHours << endl;

return 0;
}

Last edited on
Topic archived. No new replies allowed.