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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
#include<iostream>
using namespace std;
bool survey();
int main()
{
cout<<" Hello, the purpose of this program is to see if you and the person you are taking this survey with are compatible roomates"<<endl<<endl;
if (survey() == true)
cout<<" congratulations"<<endl;
else
cout<< " You are not a good match" <<endl;
system("pause");
return 0;
}
bool survey()
{
int age1, age2;
char sex1,sex2;
char answerx1, answerx2, answery1, answery2;
bool smoking1, smoking2;
bool pets1, pets2;
int results = 0;
int gender1, gender2;
bool final_answer;
cout << "Please enter your age:"<<endl<<endl;
cin >> age1;
cout<< "please enter your gender, type m for male or f for female:"<<endl<<endl;
cin >> sex1;
//cout<< sex1<<endl;
if (sex1 == 'm' || sex1 == 'M')
{
gender1 = 0;
}
else
{
gender1 = 1;
}
cout << "do you prefer non-smoking environments, please type y or n:"<<endl<<endl;
cin >> answerx1;
if (answerx1 == 'y' || answerx1 == 'Y')
{
smoking1 = true;
}
else
{
smoking1 = false;
}
cout << "do you like pets,please type y or n:"<<endl<<endl;
cin >> answerx2;
if (answerx2 == 'y' || answerx2 =='Y')
{
pets1 = true;
}
else
{
pets1 = false;
}
//This part of the survey is for the other person
cout << "Please enter your age:"<<endl<<endl;
cin >> age2;
cout<< "please enter your gender, type m for male or f for female:"<<endl<<endl;
cin >> sex2;
//cout<< sex2<<endl;
if (sex2 == 'm' || sex2 == 'M')
{
gender2 = 0;
}
else
{
gender2 = 1;
}
cout << "do you prefer non-smoking environments, please type y or n:"<<endl<<endl;
cin >> answery1;
if (answery1 == 'y' || answery1 == 'Y')
smoking2 = true;
else
smoking2 = false;
cout << "do you like pets,please type y or n:"<<endl<<endl;
cin >> answery2;
if (answery2 == 'y' || answery2 == 'Y')
pets2 = true;
else
pets2 = false;
//Now we will compare answers
//cout<< results<<endl;
//cout<< age1<< age2<<endl;
//cout << age1 - age2 <<endl;
if (age1 - age2 <= 10 || age1 - age2 >= -10)
results++;
//cout<<gender1<<gender2<<endl;
if (gender1 == gender2)
results++;
//cout<<pets1<<pets2<<endl;
if (pets1 == pets2)
results++;
//cout<<smoking1<<smoking2<<endl;
if (smoking1 == smoking2)
results++;
//now we count results
//cout<< results<<endl;
//cout<< gender1<< " "<<gender2<<endl;
if (results >= 2)
final_answer = true;
else
final_answer = false;
return final_answer;
}
|