Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstring>
- #include<cstdio>
- #include<cmath>
- using namespace std;
- int main()
- {
- while(1){
- string iteam1="",item2="";
- int sum1=0,sum2=0,sum3=0,sum4=0,total=0;
- char c;
- puts("Give item 1 name");
- cin>>iteam1;
- puts("Give item 2 name");
- cin>>item2;
- int a,b,c,d;
- cout<<"What is amount of "<<iteam1<<" and "<<item2<<endl;
- cin>>a;
- cout<<"What is amount of "<<iteam1<<" and not "<<item2<<endl;
- cin>>b;
- cout<<"What is amount of not "<<iteam1<<" and "<<item2<<endl;
- cin>>c;
- cout<<"What is amount of not "<<iteam1<<" and not "<<item2<<endl;
- cin>>d;
- sum1=a+c;
- sum2=b+d;
- sum3=a+b;
- sum4=c+d;
- total=sum1+sum2;
- cout<<" \t "<<iteam1<<" \t\t"<<"not "<<iteam1<<" \t"<<"Erow"<<endl;
- cout<<item2<<"\t "<<a<<"\t\t"<<c<<" \t\t"<<sum1<<endl;
- cout<<"not "<<item2<<" "<<b<<" \t"<<d<<"\t\t"<<sum2<<endl;
- cout<<"__________________________________________________________________"<<endl;
- cout<<"Ecol\t "<<sum3<<" \t"<<sum4<<" \t\t"<<total<<endl<<endl;
- double x,y;
- double expected=0.00;
- x= (sum1*sum3)/total;
- y= (sum3-x) ;
- cout<<" \t "<<iteam1<<" \t\t"<<"not "<<iteam1<<" \t"<<"Erow"<<endl;
- cout<<item2<<"\t "<<a<<"("<<x<<")\t"<<c<<"("<<(sum1-x)<<") \t"<<sum1<<endl;
- cout<<"not "<<item2<<" "<<b<<"("<<y<<") \t"<<d<<"("<<(sum2-y)<<")\t"<<sum2<<endl;
- cout<<"__________________________________________________________________"<<endl;
- cout<<"Ecol\t "<<sum3<<" \t"<<sum4<<" \t\t"<<total<<endl;
- expected= (((a-x)*(a-x))/x) + (((b-y)*(b-y))/y)
- + (((c-(sum1-x))*(c-(sum1-x)))/(sum1-x)) + (((d-(sum2-y))*(d-(sum2-y)))/(sum2-y)) ;
- printf("\nEx^2= %.2lf\n",expected);
- cout<<endl<<endl<<endl<<"Do you want to continue? (press Y/y for YES or N/n for NO)";cin>>c;
- if(tolower(c)=='N')break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement