ARRAYYYY PLEASE HELP ME!!!

I'm new to this and I'm a beginner at c++. I need some help with some questions that I've been trying to solve for hours. I think I got most of this one right but I got stuck at the wages array. This question says :
write a program that uses the following arrays:

-empId:an array of seven long integers to hold employee identification numbers. The array should be initialized with the following numbers : 5658845, 4520125, 7895122, 8777541, 8451277, 1302850, 7580489

- hours: an array of seven intgers to hold the number of hours worked by each employee.

-payRate: an array of seven doubles to hold each employee's hourly pay rate.

-wages: an array of seven doubles to hold each employee's gross wages.

The program should relate the data in each array through the subscripts.
The program should display each employee number and ask the user to enter that employee's hours and pay rate. It should then calculate the gross wages for that employee (hours times pay rate), which should be stored in the wages array. After the data hs been entered for all the employees, the program should display each employee's identification number and gross wages.


And this is what I have :

#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
const int numOfEmployees = 7;
int long empId[numOfEmployees]= {5658845,4520125,7895122,8777541,8451277,1302850,7580489};
int hours[numOfEmployees];
double payRate[numOfEmployees];
double wages[numOfEmployees];

cout<< "Enter the hours worked by 7 employees and their hourly pay rates.\n";
for (int count = 0;count < numOfEmployees;count++)
{
cout<< "Hours worked by employee #"<<empId[count]<< ":";
cin>> hours[count];
while (hours < 0)
{
cout<<"Please enter a positive number: ";
cin>> hours[count];
}
cout<< "Hourly pay rate for employee #"<<empId[count]<<":";
cin>> payRate[count];
while (payRate[count] < 6.00)
{
cout<< "Please enter a pay rate higher than $6.00: ";
cin>> payRate[count];
}
}

for (int count = 0;count < numOfEmployees;count++)
{
wages[count]= hours[count] * payRate[count];
cout<<"Here is the gross pay for each employee:\n";
cout<<fixed<<showpoint<<setprecision(2);
cout<< "Employee #"<<empId[count]<<": $"<<wages[count]<< endl;
}
return 0;
}



Thanks :D
Okay, you've posted the assignment, and your code (without code tags), but you've failed to ask an actual question.

My brain starts to to see a pattern ....

https://www.daniweb.com/software-development/cpp/threads/183096/need-help-with-arrays-please-

What a coincidence! Someone has asked the exact same question with the exact same wording 5 years ago. :/
But at least the other poster knew how to use code tags.

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
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
    const int numOfEmployees = 7;
    int long empId[numOfEmployees]= {5658845,4520125,7895122,8777541,8451277,1302850,7580489};
    int hours[numOfEmployees];
    double payRate[numOfEmployees];
    double wages[numOfEmployees];
    
    cout<< "Enter the hours worked by 7 employees and their hourly pay rates.\n";
    for (int count = 0;count < numOfEmployees;count++)
    {
        cout<< "Hours worked by employee #"<<empId[count]<< ":";
        cin>> hours[count];
        while (hours < 0)
        {
            cout<<"Please enter a positive number: ";
            cin>> hours[count];
        }
        cout<< "Hourly pay rate for employee #"<<empId[count]<<":";
        cin>> payRate[count];
        while (payRate[count] < 6.00)
        {
            cout<< "Please enter a pay rate higher than $6.00: ";
            cin>> payRate[count];
        }
    }
    
    for (int count = 0;count < numOfEmployees;count++)
    {
        wages[count]= hours[count] * payRate[count];
        cout<<"Here is the gross pay for each employee:\n";
        cout<<fixed<<showpoint<<setprecision(2);
        cout<< "Employee #"<<empId[count]<<": $"<<wages[count]<< endl;
    }
    return 0;
}
}
Last edited on
Topic archived. No new replies allowed.