SHOW:
|
|
- or go back to the newest paste.
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; |
16 | + | char ch; |
17 | puts("Give item 1 name"); | |
18 | cin>>iteam1; | |
19 | puts("Give item 2 name"); | |
20 | cin>>item2; | |
21 | ||
22 | int a,b,c,d; | |
23 | cout<<"What is amount of "<<iteam1<<" and "<<item2<<endl; | |
24 | cin>>a; | |
25 | ||
26 | cout<<"What is amount of "<<iteam1<<" and not "<<item2<<endl; | |
27 | cin>>b; | |
28 | ||
29 | cout<<"What is amount of not "<<iteam1<<" and "<<item2<<endl; | |
30 | cin>>c; | |
31 | ||
32 | cout<<"What is amount of not "<<iteam1<<" and not "<<item2<<endl; | |
33 | cin>>d; | |
34 | ||
35 | sum1=a+c; | |
36 | sum2=b+d; | |
37 | ||
38 | sum3=a+b; | |
39 | sum4=c+d; | |
40 | ||
41 | total=sum1+sum2; | |
42 | ||
43 | cout<<" \t "<<iteam1<<" \t\t"<<"not "<<iteam1<<" \t"<<"Erow"<<endl; | |
44 | cout<<item2<<"\t "<<a<<"\t\t"<<c<<" \t\t"<<sum1<<endl; | |
45 | cout<<"not "<<item2<<" "<<b<<" \t"<<d<<"\t\t"<<sum2<<endl; | |
46 | cout<<"__________________________________________________________________"<<endl; | |
47 | cout<<"Ecol\t "<<sum3<<" \t"<<sum4<<" \t\t"<<total<<endl<<endl; | |
48 | ||
49 | double x,y; | |
50 | double expected=0.00; | |
51 | ||
52 | x= (sum1*sum3)/total; | |
53 | y= (sum3-x) ; | |
54 | ||
55 | ||
56 | ||
57 | ||
58 | cout<<" \t "<<iteam1<<" \t\t"<<"not "<<iteam1<<" \t"<<"Erow"<<endl; | |
59 | cout<<item2<<"\t "<<a<<"("<<x<<")\t"<<c<<"("<<(sum1-x)<<") \t"<<sum1<<endl; | |
60 | cout<<"not "<<item2<<" "<<b<<"("<<y<<") \t"<<d<<"("<<(sum2-y)<<")\t"<<sum2<<endl; | |
61 | cout<<"__________________________________________________________________"<<endl; | |
62 | cout<<"Ecol\t "<<sum3<<" \t"<<sum4<<" \t\t"<<total<<endl; | |
63 | ||
64 | ||
65 | expected= (((a-x)*(a-x))/x) + (((b-y)*(b-y))/y) | |
66 | + (((c-(sum1-x))*(c-(sum1-x)))/(sum1-x)) + (((d-(sum2-y))*(d-(sum2-y)))/(sum2-y)) ; | |
67 | ||
68 | ||
69 | ||
70 | printf("\nEx^2= %.2lf\n",expected); | |
71 | ||
72 | ||
73 | ||
74 | cout<<endl<<endl<<endl<<"Do you want to continue? (press Y/y for YES or N/n for NO)"; | |
75 | - | cout<<endl<<endl<<endl<<"Do you want to continue? (press Y/y for YES or N/n for NO)";cin>>c; |
75 | + | while(tolower(ch)!='y'||tolower(ch)!='n') |
76 | - | if(tolower(c)=='N')break; |
76 | + | { |
77 | cin>>ch; | |
78 | if(tolower(ch)=='n'){cout<<"So, see you again. (o.o)"<<endl;return 0;} | |
79 | else if(tolower(ch)=='y'){cout<<"Ok lets fun again. :D"<<endl<<"___________________________________________________________"<<endl;break;} | |
80 | else cout<<"Give a valid charecter (press Y/y for YES or N/n for NO)"<<endl; | |
81 | } | |
82 | ||
83 | ||
84 | ||
85 | ||
86 | } | |
87 | ||
88 | return 0; | |
89 | } |