Array assignment question

Ok I feel kinda stupid not being able to figure this out but here goes

I have a working on a program for a class and its my first time using arrays and i got the concept but the syntax is hurting me

the input requirements are
- using a loop, prompt the user to enter 5 salaries (ill come back to that later)
-store the salaries in the array (got that)

but its the processing requirements that got me stumped
-after all 5 salaries are input computer the social security tax on each and store in another array (this is what i dont know how to do)
-output the results (i can manage that)

here is what I got
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
#include <iostream>
using namespace std;

int main ()


{
  float salary1, salary2, salary3, salary4, salary5;

  
  
  cout << "Please enter 5 salaries." << endl;
  cin >> salary1 >> salary2 >> salary3 >> salary4 >> salary5;

  float salary[5] = {salary1, salary2, salary3, salary4, salary5}
int x;
float ssTax;

for (x=0; x<1; x++)
{
	ssTax = .062 * salary[x];
}
 


}


I know thats not correct but its the best I can come up with at the moment..i have watched a few tuts on youtube and have gone over class not and my textbook. :( Any help would be great
Last edited on
You are not using arrays...
but isnt

float salary[5] = {salary1, salary2, salary3, salary4, salary5}

an array?
I think you need to use only arrays, one array for input and one for output
I'll only comment on lines 17 - 22.
The assignment is asking for an array, so define ssTax as an array (float ssTax[5];)
There are five elements in your array, so why are you looping only through the first one (x < 5)
x'th element of ssTax equals 0.062* x'th element of salary. Do you see what's missing?([x])
oops. sorry about the x < 1. I was playing around with a dumb down version of the program to test if i had done the first array right and i forgot to change it back
float ssTax[5];

for (x=0; x<5; x++)
{
ssTax[x] = .062 * salary[x];
}
something like that?
yes
Topic archived. No new replies allowed.