### Help with multi dimensional arrays!

Hello! Could come help me get started with this program?

Write a program using a multi-dimensional array that allows the user to enter payroll data for a business. Each week the employees receive pay based on the hours worked. The user wants to be able to record gross pay by the week for 4 weeks for each of the 4 employees. The program prompts the user to enter the amount for an employee in a certain week.

(This is an example of how the data should be coming on the screen)
Enter the weekly pay for employee 1 for week 1: 656.75
Enter the weekly pay for employee 2 for week 1: 825.99
Enter the weekly pay for employee 3 for week 1: 456.75
Enter the weekly pay for employee 4 for week 1: 786.75

Enter the weekly pay for employee 1 for week 2: 934,67
Enter the weekly pay for employee 2 for week 2: 825.99
Enter the weekly pay for employee 3 for week 2: 456.75
Enter the weekly pay for employee 4 for week 2: 786.75

I have been trying to start this assignment for a bit, and just cant seem to do it properly.
Last edited on
const int weeks = 4;
const int emps = 4;

double data[emps][weeks];
//remember that arrays are 0-n-1, not 1-n in this language.
data[0][0] = 656.75; //employee 1 week 1
data[3][1] = 786.75; //employee 4 week 2
Last edited on
the bottom half

Enter the weekly pay for employee 1 for week 1: 656.75
Enter the weekly pay for employee 2 for week 1: 825.99
Enter the weekly pay for employee 3 for week 1: 456.75
Enter the weekly pay for employee 4 for week 1: 786.75

Enter the weekly pay for employee 1 for week 2: 934,67
Enter the weekly pay for employee 2 for week 2: 825.99
Enter the weekly pay for employee 3 for week 2: 456.75
Enter the weekly pay for employee 4 for week 2: 786.75

all that is just an example of how the program should be running, i do not need to add that into the code
Pseudocode is always a good start once you know how a 2d array works:

1. Setup variables
2. Setup array[employees][weeks]

loop::

5. Ask for pay for that week
6. Store pay for that week in array[employee number][week number]
7. If that's the finish then End otherwise go back to loop:

8. End
 I have been trying to start this assignment for a bit, and just cant seem to do it properly.

First design, then code from the design. Once you have the design, code in small parts from the design and compile and test each part before coding the next part. againtry has given you a good start with some pseudocode.

Do you understand arrays in C++. Have a look at https://www.learncpp.com/cpp-tutorial/arrays-part-i/

Topic archived. No new replies allowed.