Basic math always returning a value of "0"

Hey guys, I'm sure I'm making a silly error somewhere, but every time I run my code, I'm getting back "0" and I can't figure out why. Whenever I do the same calculation on my calculator I'm getting completely different results.

Here is the portion of the code that is supposed to be making a calculation. Thanks in advance for any answers!

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
void zValue(double sampleMean, double populationMean, double populationSTDV, double sampleSize)
{
	const string message1 = "Enter your vaules for the Z score.";
	double totalZ = ((sampleMean) - (populationMean)) / ((populationSTDV) / sqrt(sampleSize));
	cout << "Let's calculate the Z value." << endl;
	cout << message1 << endl;
	cout << "What is the sample mean? " << endl;
	cin >> sampleMean;
	cout << "What is the population mean? " << endl;
	cin >> populationMean;
	cout << "What is the population standard deviation? " << endl;
	cin >> populationSTDV,
	cout << "What is the sample size? " << endl;
	cin >> sampleSize;
	cout << "The Z value is: " << totalZ << ".\n";

	//Loop
	int Yes = 1;
	int No = 2;
	int exitLoop;
	cout << "Would you like to terminate the program?" << endl;
	cout << "Press '1' for yes and any other number for no.";
	cin >> exitLoop;
	while (exitLoop < 1 || exitLoop > 1)
	{
		cout << message1;
		cin >> exitLoop;
	}
	
}
¿how are you calling your function?

lines 5 to 14 are useless, you are trying to modify copies of the parameters.
I see that you are trying to calculate totalZ on line 4, before the user has entered any values. Have a think about how much sense that makes.
Last edited on
Topic archived. No new replies allowed.