Advertisement
Eather

corelationanalysis

Mar 5th, 2012
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.10 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstring>
  3. #include<cstdio>
  4. #include<cmath>
  5. using namespace std;
  6.  
  7.  
  8. int main()
  9. {
  10.  
  11.  
  12.  
  13.     while(1){
  14.         string iteam1="",item2="";
  15.         int sum1=0,sum2=0,sum3=0,sum4=0,total=0;
  16.         char c;
  17.         puts("Give item 1 name");
  18.         cin>>iteam1;
  19.         puts("Give item 2 name");
  20.         cin>>item2;
  21.  
  22.  
  23.         int a,b,c,d;
  24.  
  25.         cout<<"What is amount of "<<iteam1<<" and "<<item2<<endl;
  26.         cin>>a;
  27.  
  28.         cout<<"What is amount of "<<iteam1<<" and not "<<item2<<endl;
  29.         cin>>b;
  30.  
  31.     cout<<"What is amount of not "<<iteam1<<" and "<<item2<<endl;
  32.         cin>>c;
  33.  
  34.     cout<<"What is amount of not "<<iteam1<<" and not "<<item2<<endl;
  35.         cin>>d;
  36.  
  37.         sum1=a+c;
  38.         sum2=b+d;
  39.  
  40.         sum3=a+b;
  41.         sum4=c+d;
  42.  
  43.         total=sum1+sum2;
  44.  
  45.         cout<<"      \t "<<iteam1<<" \t\t"<<"not "<<iteam1<<" \t"<<"Erow"<<endl;
  46.         cout<<item2<<"\t   "<<a<<"\t\t"<<c<<" \t\t"<<sum1<<endl;
  47.         cout<<"not "<<item2<<"  "<<b<<" \t"<<d<<"\t\t"<<sum2<<endl;
  48.         cout<<"__________________________________________________________________"<<endl;
  49.         cout<<"Ecol\t    "<<sum3<<" \t"<<sum4<<" \t\t"<<total<<endl<<endl;
  50.  
  51.         double x,y;
  52.         double expected=0.00;
  53.  
  54.         x= (sum1*sum3)/total;
  55.         y= (sum3-x) ;
  56.  
  57.  
  58.  
  59.  
  60.         cout<<"      \t "<<iteam1<<" \t\t"<<"not "<<iteam1<<" \t"<<"Erow"<<endl;
  61.         cout<<item2<<"\t   "<<a<<"("<<x<<")\t"<<c<<"("<<(sum1-x)<<") \t"<<sum1<<endl;
  62.         cout<<"not "<<item2<<"  "<<b<<"("<<y<<") \t"<<d<<"("<<(sum2-y)<<")\t"<<sum2<<endl;
  63.         cout<<"__________________________________________________________________"<<endl;
  64.         cout<<"Ecol\t    "<<sum3<<" \t"<<sum4<<" \t\t"<<total<<endl;
  65.  
  66.  
  67.         expected= (((a-x)*(a-x))/x) + (((b-y)*(b-y))/y)
  68.                 + (((c-(sum1-x))*(c-(sum1-x)))/(sum1-x)) + (((d-(sum2-y))*(d-(sum2-y)))/(sum2-y)) ;
  69.  
  70.  
  71.  
  72.         printf("\nEx^2= %.2lf\n",expected);
  73.  
  74.  
  75.         cout<<endl<<endl<<endl<<"Do you want to continue? (press Y/y for YES or N/n for NO)";cin>>c;
  76.         if(tolower(c)=='N')break;
  77.  
  78.     }
  79.  
  80.     return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement