It's my assignment I have done almost I have completed it.But I have problem in getting input from user(the bank name)here is my assignment question.
Customer often wait in the bank..!you have to ask the user the entire as many bank names as he desires and time (waiting time the user waited)
in the following format.
HSBC BANK | 6.4 6.6 7.5 2.2 3.4 5.6 |
Lloyds bank | 5.3 2.3 3.4 5.3 3.4|
the program should calculte the standard deviation and mean.
and the one with least standard deviation should be informed to the user!
The calculation part works perfectly fine,I don't know how to make it in that format!if I use cin.getline it goes to next line after the user inputs the name,so it will change the required format!please help me in getting it in that format!THANKS
#include<iostream>
#include<cmath>
void Mean(double arr[],double size,double &counter,double &mean,double &declared,double sum);
void standardDeviation(double deviation,double &mean,double &counter,double variance,double power,double now,double temp,double arr[],double &declared);
using namespace std;
int main()
{
double sum = 0,mean = 0,counter = 0,size = 100,declared = 0 ,variance = 0,now =0,temp =0,power=0,deviation = 0;
double arr[1000];
cout<<"enter size"<<endl;
cin>>declared;
cout<<"enter input"<<endl;
Mean(arr,size,counter,mean,declared,sum);
standardDeviation(deviation,mean, counter, variance, power, now, temp, arr,declared);
cout<<endl;
system("pause");
}
void Mean(double arr[],double size,double &counter,double &mean,double &declared,double sum)
{
for(int i=0;i<declared;i++)
{
cin>>arr[i];
if(arr[i]=='\0')
break;
sum+=arr[i];
counter++;
}
// cout<<"counter is: "<<counter;
//cout<<"sum is : "<<sum<<endl;
mean=sum/counter;
counter=counter;
cout<<"mean is: "<<mean<<endl;
}
void standardDeviation(double deviation,double &mean,double &declared,double variance,double power,double now,double temp,double arr[],double &counter)
{
for(int i =0; i<counter;i++)
{
now= arr[i]-mean;
//cout<<"value: "<<i+1<<"is: "<<now<<" ";
power=pow(now,2);
//cout<<"power of: "<<i+1<<"is: "<<power<<endl;
temp+=power;
}
//cout<<"sum of powers are: "<<temp<<endl;
counter=counter-1;
variance=temp/counter;
//cout<<"Standard Variance"<<variance<<endl;
deviation=sqrt(variance);
cout<<"Standard Deviation is: "<<deviation;
}