question archive To be done in C++ and no complex C++ just begineer/intermediate language and no use of cout and cin jus use printf and scanf Question 1: Wheel of Fortune! If you ever watched the game show "Wheel of Fortune!" you'll know that contestants have to solve a puzzle

To be done in C++ and no complex C++ just begineer/intermediate language and no use of cout and cin jus use printf and scanf Question 1: Wheel of Fortune! If you ever watched the game show "Wheel of Fortune!" you'll know that contestants have to solve a puzzle

Subject:Computer SciencePrice: Bought3

To be done in C++ and no complex C++ just begineer/intermediate language and no use of cout and cin jus use printf and scanf
Question 1:
Wheel of Fortune! If you ever watched the game show "Wheel of Fortune!" you'll know that contestants have to solve a puzzle. The clue is a multi-word text string (an expression, a place, etc) with the characters blanked out. Typically, you need to "buy" vowels but in this assignment all vowels and special characters are shown to the user. Only the consonants are hidden. Your wheel of fortune function will take a char string answer as input and output a char string "clue" with all the consonants removed:
Example: char * a_ puzzleTxt = wheelOfFortune("HELLO--WORLD");
// would mean a_puzzleTxt stores "_E__O--_O___".
• You may assume that the answers are all capital letters. o Bragging Bonus (do it for glory...you just don't get points for doing this): Make the function work for upper and lower case characters
• The letter 'Y' is considered a consonant, despite it sometimes being a vowel.
• wheelOfFortune that takes a character array (char* a_answer for example) as an input parameter and returns a char array (char* is the return type).
• You should not modify a_answer. Therefore, you will need to make a new char array to put your answer. You will return that new array.
• In the main method, test our wheelofFortune function with a variety of different "answers". You can use a printf statement to see what the answers and the corresponding puzzles will be. You can use those same answers in your wheel of torture testing.
The returned array:
• Temporarily (don't pass this in) make a static char array of size 200 and use that for the array you return.
o What's wrong with that solution?
o You should be able to type all the code and things will compile. What happens when you test this? (think about this. No need to give an answer)
After trying this with a static array, use malloc (and free it later in the main function) to make a dynamic character array. o You are not allowed to use new or delete (C++ code).
o We will use new / delete in BIT 2400.
o NOTICE: strlen returns the length of a string...but it does not include the 0 at the end. That was my bug when I did the assignment. The error returned can be difficult to figure out so I wanted to point this out. 
• Hint 2: You may want to write a helper function or two. Otherwise the code can get hard to debug and you replicate code.
o For example, maybe you can write a function convertChar that takes a single char as a parameter and returns a char that is '_' or the original parameter character if not a consonant.
o You aren't forced to write this function, but I am very strongly hinting that it would be useful. I am trying to teach you how to break down big problems into smaller reusable parts after all. :)


Task 2: wheelOfTorture (no []):
Now that you've made wheel of fortune the easy way, make a function wheelOfFortune2 that takes the same input and returns the same output. The function should be almost identical to wheelOfFortune, HOWEVER, you are not allowed to use []. You can only get the array elements using & or *. This is to give you practice.
• Test wheelOfFortune2 using the same c-strings in the main method. Also, add the following test for each of your strings
char* clue1 = wheelOfFortune(a_answer1);
char* clue2 = wheelOfFortune2(a_answer1);
assert(strcmp(clue1, clue2) == 0); 
Strcmp is "string compare" and returns 0 if two character strings are identical. If they are different, it returns a negative or positive based on the first character that does not match in the two strings.....essentially it should always return 0 in our case. 


 the two strings.....essentially it should always return 0 in our case.
• By the way, this is not a good use of an assert. Asserts should be for things that should always be true (like an index is >= 0) and work as a sanity check but let's ignore that fact. The two functions should always return the same thing.
• Reminder where asserts are useful: After making the dynamic array a_puzzle using malloc, assert(a_puzzle != NULL);.....essentially assert that the memory was allocated like you requested. If something went wrong, it went VERY wrong.

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE