Trouble not completing the loop

I am having some trouble with when it asks me after it asks me to "Enter the number of registrants (negative vaule to stop)" it doesn't continue. Not sure what is wrong. Would someone please critique this for me? Much appreciative. Also, the "cout << fixed << setprecision(2);" has got a red squiggly line underneath it. I am getting an error C3861: 'setprecision': identifier not found.

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
36
37
38
#include <iostream>
using namespace std;
int main()
{
	//Variables
	int numRegistered = 0;
	double totalCharge = 0.0;
	int totalRegistered = 0;
	double avgChar	= 0.0;

	//bring loop

	while (numRegistered >= 0)
	{
		if (numRegistered < 4)
			totalCharge += (numRegistered * 150);
		else if (numRegistered >= 4 && numRegistered < 10)
			totalCharge += (numRegistered * 100);
		else
			totalCharge += (numRegistered * 90);
			totalRegistered += numRegistered;
			cout << "Enter the number of registrants (negative vaule to stop): ";
			cin >> numRegistered;
	}
	if (totalRegistered == 0)
		avgChar = 0;
	else
		avgChar = totalCharge / totalRegistered;
		cout << fixed << setprecision(2);
		cout << "Total charge is $" << totalCharge << endl;
		cout << "Total number of registrants is: " << totalRegistered << endl;
		cout << "Average cost per person is $ " << avgChar << endl;
	return 0;	
 
system("pause");
return 0;
}
//end of main function 
Replace: Cout << fixed << setprecision (2);

With: cout << fixed;
cout.precision(2);
demon11777

thank you. That took the red line out from underneath the cout << fixed << setprecision(2);. It works fine.
I am having some trouble with when it asks me after it asks me to "Enter the number of registrants (negative vaule to stop)" it doesn't continue.


What do you mean it doesn't continue?

And you need to #include <iomanip> to use the stream manipulators like setprecision.
Topic archived. No new replies allowed.