This my code i am doing a bar chart that input from file but it can't works.
can anyone of you help me??
#include <iostream>
#include <cmath>
#include <iomanip>
#include <fstream>
using namespace std;
int main ()
{
int psi[7];
int psiall=0;
int counter=0;
long double sum=0;
long double average,sd;
long double variance=0;
long double sumsqr=0;
double value;
ifstream mypsi("allpsi.txt");
ifstream psi1("allpsi.txt");
cout <<"Hi,User!\n";
cout <<"So, we will help you to calculate your Total of PSI, mean and standard deviation.\n";
for (int day = 1; day <= 7; day++)
{
mypsi>>psiall;
cout << "The day " << day << " psi is: "<<psiall<<"\n";
sum+=psiall;
sumsqr+=pow(psiall,2);
}
cout << "The total PSI : " <<sum<<"\n";
average=sum/7;
cout << "The mean : " <<average<<"\n";
variance = (sumsqr/7) - pow(average,2);
sd=sqrt(variance);
#include <iostream>
#include <cmath>
#include <iomanip>
#include <fstream>
using namespace std;
int main ()
{
int psi=0;
int psiall=0;
int generate[4];
long double sum=0;
long double average,sd;
long double variance=0;
long double sumsqr=0;
int c1=0;
double value;
ifstream mypsi("allpsi.txt");
ifstream psi1("allpsi.txt");
cout <<"Hi,User!\n";
cout <<"So, we will help you to calculate your Total of PSI, mean and standard deviation.\n";
for (int day = 1; day <= 7; day++)
{
mypsi>>psiall;
cout << "The day " << day << " psi is: "<<psiall<<"\n";
sum+=psiall;
sumsqr+=pow(psiall,2);
}
cout << "The total PSI : " <<sum<<"\n";
average=sum/7;
cout << "The mean : " <<average<<"\n";
variance = (sumsqr/7) - pow(average,2);
sd=sqrt(variance);