hi ,
i need help to complete wrting a program
//
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
//decaler data here
double var, n=0, sum = 0;
double x, xi;
//input
cout << "please enter the value of x :";
cin >> x;
cout << "please enter the value of xi :";
cin >> xi;
//calculations
while (xi > 0) {
cout << "please enter the value of xi :";
cin >> xi;
sum += pow((xi - x), 2);
n++;
}
cout << "the number of observation is :" << n << endl;
cout << "the sum of (xi-x)2 is :" << sum << endl;
//computaion
var = (sum / n);
//output
cout << "the variance is :" << var << endl;
//process
if (var < 10)
{
cout << "the flag vlaue is:" << 'A';
cout << "Excellent observation";
}
else if (var >= 10 && var < 15) {
cout << "the flag vlaue is:" << 'B';
cout << "Normal observation";
}
else if (var >= 15 && var < 20) {
cout << "the flag vlaue is:" << 'C';
cout << "Acceptable observation";
}
else if (var >= 20){
cout << "the flag vlaue is:" << 'D';
cout << "Not acceptable at all";
}
else
cout << "Errors";
system("pause");
return 0;
}
this what i wrote ,
acutely it work well until (the number of observation)
but it give me wrong vlaue for (the sum of (xi-x)2) and (the variance ) !!
also if statement does not work at all ?
help me please :( i should submit the assignment ,