setprecision help

here is my code in the sales summary at the end i am not sure where and how to put the setprecision so that it works for all of them... also can someone tell me why numbers keep popping up after the summary and i am not sure why it is they are.

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
#include <iostream>
#include <iomanip>
using namespace std;
const int SIZE = 8;//size of array
int main()
{
	int quanity[SIZE];
	double price[SIZE];
	double total[SIZE];
	cout<<"Enter the price per product and the quanity "<<endl;
	for (int i = 0; i < SIZE; i++)
	{
		cout<<"Price for product "<<i+1<<" : "<<endl;
		cin >> price[i];
		cout<<"Quanity of product "<<i+1<<" : "<<endl;
		cin>> quanity[i];
	}
	
	for (int i = 0; i < SIZE; i++)
	{
		total[i]= price[i]*quanity[i];
	}
	
	cout<<"The sales summary is: "<<endl;
	cout<<"Price  Quanity  Total"<<endl;
	cout<< price[1]<<"	"<<quanity[1]<<"	"<< total[1]<<endl;
	cout<< price[2]<<"	"<<quanity[2]<<"	"<< total[2]<<endl;
	cout<< price[3]<<"	"<<quanity[3]<<"	"<< total[3]<<endl;
	cout<< price[4]<<"	"<<quanity[4]<<"	"<< total[4]<<endl;
	cout<< price[5]<<"	"<<quanity[5]<<"	"<< total[5]<<endl;
	cout<< price[6]<<"	"<<quanity[6]<<"	"<< total[6]<<endl;
	cout<< price[7]<<"	"<<quanity[7]<<"	"<< total[7]<<endl;
	cout<< price[8]<<"	"<<quanity[8]<<"	"<< total[8]<<endl;
	return 0;
}



here is the link to my .cmd if anyone is confused by what i mean

http://s15.postimage.org/5sqe74kvf/Untitled.png
Your array has a size of 8, so valid indexes are only 0 to 7, not 1 to 8.
Topic archived. No new replies allowed.