-
Notifications
You must be signed in to change notification settings - Fork 0
/
ofosu-standarddev.cpp
110 lines (73 loc) · 1.88 KB
/
ofosu-standarddev.cpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <fstream>
using namespace std;
struct LabReading
{
float AlphaEnergies;
int Total_Impulses;
};
void Standard_Deviation(LabReading);
int main()
{
LabReading Temp;
cout<<endl;
cout<<endl;
Standard_Deviation(Temp);
ifstream readdata ("Data9.txt");
string header;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<"Displaying Experimental Results In A Tabular Form"<<endl;
cout<<endl;
cout<<"Alpha Energies Readings (E/KeV)"
<<setw(25)<<"Impulse Reading"<<endl;
if(readdata.is_open())
{
getline(readdata,header);
while(!readdata.eof())
{
readdata>>Temp.AlphaEnergies
>>Temp.Total_Impulses;
cout<<fixed<<showpoint<<setprecision(1)<<Temp.AlphaEnergies<<setw(45)
<<Temp.Total_Impulses<<endl;
}
readdata.close();
}else cout<<"ERROR......Input File Not Found\nPlease Try again"<<endl;
cout<<endl;
cout<<endl;
system ("pause");
return 0;
}
void Standard_Deviation(LabReading temp)
{
ifstream readfile ("Data9.txt");
string line;
int total,sum;
float mean, variance, stdDeviation;
if(readfile.is_open())
{
getline(readfile,line);
while(!readfile.eof())
{
readfile>>temp.AlphaEnergies
>>temp.Total_Impulses;;
sum+= temp.AlphaEnergies;
total += temp.Total_Impulses;
}
mean = sum/9;
variance += pow(temp.AlphaEnergies - mean, 2);
variance = variance/9;
stdDeviation = sqrt(variance);
cout<<"The standard deviation of the Alpha"
<<" Energy Readings are: "
<<stdDeviation<<endl;
cout<<"The sum total of the impulses"
<<" recorded in the experiment are: "<<total<<endl;
readfile.close();
}else cout<<"ERROR......Input File Not Found\nPlease Try again"<<endl;
}