Hi! I'm currently taking a computer programming course at Wagner college and I have a project due this week that I am completely stumped on. these are the guidelines:

This will be a something like a “compatibility program”.
1) You will ask the user their name, and store it.
2) You will ask the user a yes or no question. Have them enter y/Y or n/N for an answer.
3) Compare the users answer to your answer, and output the result.
4) Ask another question, this time with 3 possible answers.
5) Again, compare users answer with yours and output the result.
6) Ask them one more question, that may involve a more than one word answer.
7) Compare that answer with yours and output that result.
8) After that last question, output the compatibility score between you and the user. 1/3 or 2/3 or 3/3 along with a statement involving their name. (This is the intuitive part of the program, its not hard, but its something that is happening behind the scenes)

I can do a majority of this programming, but for some reason, when it comes to separating my yes or no answers, it won't work, and as for calculating the compatibility, i'm not sure how to do that either. My teacher wasn't much of a help, so does anyone have any suggestions?

Recommended Answers

All 8 Replies

Proposals are. And the first of them - show the code.

show some ideas of yours and we could guide you from there.

Proposals are. And the first of them - show the code.

I'm essentially finished with the program itself, I just have no idea how to compute the compatibility part. That's really the only thing I need help with at this point. If you could, that's be amazing! PS - It's a really ridiculous/dumb program, haha.

#include<iostream>
#include<string>
using namespace std;

int main ()

{
string first_name;
string last_name;
cout<< "please enter your first name!\n";
cin>>first_name;
cout<<"please enter your last name!\n";
cin>>last_name;

cout<<"hello"<<" "<<first_name<<" "<<last_name<<" "<<"! It is so very nice to meet you. You're probably wondering why I'm so curious about you. I totally don't blame you! It's just that...well, I...I'm really not compatible with my boyfriend anymore. I'm kinda tired of him.\n";
cout<<"So...yeah...\n";

string answer;
cout<<"Do you think you can keep a secret? y/n?\n";
cin>>answer;
if (answer == "y" || answer == "Y")
cout<<"Oh, we're off to a good start. It seems you're just as mischievous as I am ;].\n";
else
{
cout<<"Well, then. You're boring. But, I guess may as well ask you the next question. Perhaps you have some rewarding qualities.\n\n";
}

string answer2;
cout<<"So...\n";
cout<<"What kind of date would you rather go on? (romantic, fun, or both) I hope you pick the same thing I do!\n";
cin>>answer2;
if (answer2 == "both" || answer2 == "BOTH" || answer2 == "Both")
cout<<"Oh, we're meant to be! This is fantastic!\n\n\n";
{
if (answer2 == "romantic" || answer2 == "Romantic" || answer2 == "ROMANTIC")
cout<<"But...but...what about the FUN?!\n\n\n";
if (answer2 == "fun" || answer2 == "Fun" || answer2 == "FUN")
cout<<"Well...without the romance, we may as well be just friends. And, you know, that's all great and wonderful, but...\n\n\n";
}


cout<<"Okay, Mr. Patient! Only one more question.\n\n";
cout<<"How do you feel about becoming a hit man?\n";
cout<<"LAWLZ, jaykay! sorta...\n";
cout<<"Seriously, though. How do you feel about cheating on a whole? (please answer in a complete sentence, at least two words with proper punctuation. Yes, I'm picky.)\n";

string answer3;
cin>>answer3;


if (answer3 == "It's okay." || answer3 == "it's okay." || answer3 == "IT'S OKAY.")
cout<<"Oh, you perfect person, you! We were meant to be!\n\n";

else
{
cout<<"Well, if you're kinda iffy about it, I guess I can agree with that. Cheating is totally not the answer!\n\n";
}


return 0;
}

Put a counter in with the (appropriate) if statements you've already defined (when a match happens, register one more on the counter). In the end, output the counter.

Put a counter in with the (appropriate) if statements you've already defined (when a match happens, register one more on the counter). In the end, output the counter.

unfortunately we haven't done counters yet, so i'm not sure how to use them. is there any simple way you could explain it to me? sorry to be a bother.

declare a variable as count at the top of main (what would be a good type for that variable if it's going to hold 0,1,2,3...), set it to zero. Each time your condition is met (so when your if statement is saying yes, the users input has matched the desired value), increment your counter (that is, assign the value of variable+1 back to variable).
At the end, cout << count<<"/3 \n"; If you get stuck, post back, but flip ahead a few pages in your text too. I know you may not have covered the topics yet, but you probably can create it out of stuff you are already familiar with.

declare a variable as count at the top of main (what would be a good type for that variable if it's going to hold 0,1,2,3...), set it to zero. Each time your condition is met (so when your if statement is saying yes, the users input has matched the desired value), increment your counter (that is, assign the value of variable+1 back to variable).
At the end, cout << count<<"/3 \n"; If you get stuck, post back, but flip ahead a few pages in your text too. I know you may not have covered the topics yet, but you probably can create it out of stuff you are already familiar with.

thank you so much! i finally was able to make it work. i hope i get an A on my project, haha. thanks again! :D

And, you're very welcome!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.