Advertisement
payjack

Untitled

Oct 3rd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.78 KB | None | 0 0
  1. //Standard Deviation Project
  2. //Olivia Pagach pd2A
  3. //Start 10-3-17
  4. //End
  5.  
  6. #include<iostream>
  7. #include<iomanip>
  8. #include<math.h>
  9.  
  10. using namespace std;
  11.  
  12. double mean (double a, double b, double c, double d, double e){
  13.  
  14.     double m1 = double (a+b+c+d+e)/5.0;
  15.     return m1;
  16. }
  17.  
  18. double findSD (double a, double b, double c, double d, double e, double m1){
  19.  
  20.     double p1 = (a-m1)*(a-m1);
  21.     double p2 = (b-m1)*(b-m1);
  22.     double p3 = (c-m1)*(c-m1);
  23.     double p4 = (d-m1)*(d-m1);
  24.     double p5 = (e-m1)*(e-m1);
  25.  
  26.     double sd = sqrt ((p1+p2+p3+p4+p5)/5.0);
  27.     return sd;
  28. }
  29.  
  30. int findR (double sd, int range){
  31.  
  32.     if (sd<10)
  33.         range=1;
  34.  
  35.     if (10<=sd<20)
  36.         range=2;
  37.  
  38.     if (sd>=20)
  39.         range=3;
  40.  
  41.  
  42.     return range;
  43. }
  44.  
  45.  
  46. void input(double & a, double & b, double & c, double & d, double & e){
  47.  
  48.     cout<<"Welcome to Olivia's Standard Deviation Calculator!"<<endl;
  49.     cout<<"Please enter 5 values:"<<endl;
  50.     cin>>a;
  51.     cin>>b;
  52.     cin>>c;
  53.     cin>>d;
  54.     cin>>e;
  55.     cout<<"Calculating..."<<endl;
  56.     return;
  57. }
  58.  
  59. void output(double m1, double sd, int range){
  60.  
  61.     cout<<"The mean is "<<m1<<endl;
  62.     cout<<"The standard deviation is "<<sd<<endl;
  63.  
  64. cout<<setprecision(3);
  65. cout.setf(ios::showpoint | ios::fixed);
  66.  
  67.     if (range == 1);
  68.         cout<<"range:low"<<endl;
  69.  
  70.     if (range == 2);
  71.         cout<<"range:medium"<<endl;
  72.  
  73.     if (range == 3);
  74.         cout<<"range:high"<<endl;
  75.  
  76. }
  77.  
  78.  
  79. int main (){
  80.  
  81.     double a;
  82.     double b;
  83.     double c;
  84.     double d;
  85.     double e;
  86.     double p1;
  87.     double p2;
  88.     double p3;
  89.     double p4;
  90.     double p5;
  91.     double sd;
  92.     double m1;
  93.     int range;
  94.  
  95.     mean (a,b,c,d,e);
  96.     findSD (a,b,c,d,e,m1);
  97.     findR (sd,range);
  98.     input(a,b,c,d,e);
  99.     output(m1,sd,range);
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement