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<< "Employee #"<<empId[count]<<": $"<<wages[count]<< endl;
	return 0;

Thanks :D

Recommended Answers

All 2 Replies

What's got you stuck? You pretty much have the problem done.

Your last loop is doing the wage calculations and storing them in the correct array. As I read the assignment, you shouldn't be doing output in that loop. As you have it, it's giving a heading that really should not be repeated.

So modify the last bit as
loop that calculates wages

display heading that wages for all will be listed

loop that displays each employee ID and their wage

Thanks :) that was helpful. I didn't notice it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.