Question
You must implement: void enter(); which should communicate with the user via the console. It has the following very tight script. You need to adhere
You must implement:
void enter();
which should communicate with the user via the console. It has the following very tight script. You need to adhere to it as accurately as possible to score the most points.
-
Immediately upon being invoked, it must curtly greet the user (via std::cout) using the string "What?" Note that there is no space after the question mark. It must be followed by one newline.
-
Then enter an infinite loop. In each iteration of this loop,
-
You must read a whole line of input from the user and respond to each as below
(sequence is important, and responses must end in a newline)
-
If the user's input is an empty string, you must print the "What?" line again and
short-circuit back to the top of the loop (skip the rest of the steps below).
-
Print 4 spaces followed by the user's input and two newlines.
-
If the user input contains an exclamation mark(!), you must print the line
"OMG! You don't say!! " followed by the user input and exactly five exclamation marks. Then revert to the top of the loop.
-
If the user input contains either of the words "why" or "what", you must print the string "I'm sorry, I don't like questions that contain what or why." Then revert to the top of the loop.
-
If the user input contains the letter s, then you must print two lines as follows and then revert to the top of the loop.
i. "Interethting. When did you thtop thtopping your thibilanth?"
-
Page3of6
ii. the return value of your lispify() function called with user_input as its parameter, followed by the string "! Sheesh! Now what?"
-
If the user says bye or quit (or Bye or Quit), print the message "Ok Bye. Nice being a force of change in your life." and break out of your loop.
-
If none of the above conditions matches you must do the following:
-
80% of the time print the return value of rotate_vowels() invoked
using the user input as its parameter, followed by a question mark.
-
20% of the time print the string "Huh? Why do you say: "
followed by the user input and then a question mark.
-
To do the 80/20 split, here's what you do:
-
Generate a random number (use rand())
-
Calculate the remainder after dividing by 10 (This would be rand() % 10)
-
If the remainder is 8 or 9, then follow option (ii). Else follow option (i)
-
Important: Use portions of 10, not 100.
It is important that you don't call srand() ANYWHERE in your submitted code. I need to be able to control the seed to test your code.
Here is what I got so far, I got the lipsify
string lispify(string my_string){
/*
In this what I have done is initialize empty string(new_string).
Iterator through the parameter and if the character at the index is 's' then added 'th' to the the new stirng,
if the character at the index is 'S' then added 'Th' to the new string,
else added the same character from the given parameter.
Finally returing the new string.
*/
string new_string = "";
for(int i=0;i if(my_string[i]=='s'){ new_string+="th"; } else if(my_string[i]=='S'){ new_string+="Th"; } else if(my_string[i]==' '){ new_string+=""; } else{ new_string+=my_string[i]; } } return new_string; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started