HELP! array problem can't figure this out!

Can anyone help me with this problem? I can't figure it out. it's multiplying the total price not each buyers input :( can anyone help me to fix this program? thanks in advance I really need it now :(
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
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
	double a[5][4], b(0);
	int x,y;
	cout.setf(ios::fixed);
	cout.setf(ios::showpoint);
	cout.precision(2);
	cout<<"Enter five item price for each buyer\n";
	for (x=0;x<5;x++){
		cout <<"Buyer #" << x+1 << endl;
			for (y=0;y<4;y++){
				cin >> a[x][y];
			}
	}
	cout << setw(10) <<"Buyer"
		 << setw(30) <<"Item price"
		 << setw(30) <<"Total price"
		 << endl;
	for (x=0;x<5;x++){
		cout << setw(10) << x+1;
		for (y=0;y<4;y++){
			cout << setw(10) << a[x][y];
			b+=a[x][y];
		}
		cout << setw(15) <<b <<endl;
	}
	return 0;
}


here's the code :( please help me guys :(
PLEASE I NEED IT NOW T.T
Reset b to zero in your loop ?

cout << setw(15) <<b <<endl;
b=0;
@titepanatiks
1. I don't see a multiplication arithmic operator anywhere.
2. You should declare your array and regular double variable on different lines as this is a good habit.
3. Your mistake is probably not using the variables, arrays you declared right, a math error, and/or a semantic error (logic error).
Topic archived. No new replies allowed.