In C++ I need to write a program that simulates a questionnaire to find a roomma
ID: 3764101 • Letter: I
Question
In C++ I need to write a program that simulates a questionnaire to find a roommate. You will ask the user various questions that might determine a suitable match, such as their age, gender, smoking preference, sleeping habits, pets, etc. Use an overloaded function, called match, to determine if their preferences match your own. The match functions will take a string, Boolean, floating-point, or integer parameter depending on the question, and return a Boolean value. The questions themselves will be contained in a function, which returns a Boolean value indicating whether the roommate is a match (depending on an acceptable number of matches on the questionnaire). Not sure how to go about this. Any help or insight would be greatly appreciated. Thank you very much.
Explanation / Answer
count to keep the count of how many matches you get:
int count = 0;
public boolean match(String s, String myS) {
if(s == myS) {
count++; // that's whatever matches you've gotten so far + 1
return true;
}
return false; // if it's not true it's false :P
}
public boolean match(int x, int myX) {
if(s == myS) {
count++; // that's whatever matches you've gotten so far + 1
return true;
}
return false; // if it's not true it's false
}
// ETC... and for the main method you'll have (adapted to C++ of course):
public boolean matchingRoomate() {
String gender;
int age, pets;
boolean smoking;
//etc..
// prompt user for info here
match(theirAnswer, yourAnswer); // do this several times, one for each question, obviously
// finally determine if he or she is a match:
if(count > 5) { // count can be w/e you want, remember that count means how many total matches you got with roommate
return true; }
return false; // else return false;
}