The Internet ends at GF
30th August 2008
I got this homework to do for IT in Visual Basic, and I need some help.. Here is the task: Did you ever send a text message with your name and your true loves name to get a response on how compatible you are? If you haven’t then you don’t know what you are missing (besides the money it costs). I spent $3 and this was the reply they sent me :- “John loves Mary 71.43%. I think you guys should get married.” YOUR TASK You are to write an application that asks for the names of two people and works out their compatibility based on some type of calculation (that part is up to your ingenuity). Then based on their compatibility you should display a comment that is relevant (eg you wouldn’t tell them to get married if they were only 5.89% compatible). You should get the same result regardless of the order in which you put in the names. I have absolutly no idea how to even start, could someone please help me? Thanks
Shizzle my nizzle
28th July 2004
It's all about splitting the program into segments. This is how I would do it:
The first thing to do is to calculate the compatibility. Because the result must be the same regardless of the order of each name (i.e. John loves Mary must yield the same score as Mary loves John), you must think of a way of calculating a value which doesn't depend on the order of the names. What I would do would be to join the two names into one string, i.e. maryjohn or johnmary and then work out the length of the word, in this case 8 (notice how both maryjohn and johnmary are 8 characters long - this is working so far...). Then you can do something with this 8 in order to get a percentage. For example, multiply it by 628.34 then convert the result into a string and grab the first two numbers as the integers and the second two numbers as the decimals (e.g. 8 * 628.34 = 5026.72. Turn this number into a string - "5026.72", then grab the first two numbers - 50, and the second two numbers, 26, and make this your number - 50.26%).
The second part is the comment. All you have to do is come up with a bunch of comments for different levels of percentages and find which 'level' the number you've created is in. Just do a bunch of IF statements, e.g.
If number > 90 then comment = "You should get married." Elseif number > 70 then comment = "Great match." Elseif number > 50 then.... 'And so on(That's assuming your percentage is stored in the variable 'number' and your comment variable is named 'comment')
The rest shouldn't be too difficult.
I didn't make it!
first off id google compatability test and try and find out how they work and use that as a basis of you algorithm design. are you using vb6 or .net to right this application im guessing you'll have something like two text text boxes and a command button to execute the program. what was said above is a good idea but i wouldnt use if elseif due to slow execution after more than 2 or 3 try the switch/case statement much quicker and cleaner
if you give me more info then i may be able to help out mroe
hopefully you can get the basic idea of how it works from it
it basically takes each letter in turn and if certain letters are in it it adds 2 to a variable once all of the letters have been check it is then used to calculate the compatability by using lengths of each name and halving it.
hope this has helped out