Question: In addition to the main function that we've been using, the program will need three programmer-defined functions. These functions will work together to repeat

In addition to the main function that we've been using, the program will need three programmer-defined Part B - Function Prototypes For the second part of the lab activity, you will be practicing writing function And if the user picks to repeat two messages: Enter 1 to repeat one message or enter 2 to repeat two

In addition to the main function that we've been using, the program will need three programmer-defined functions. These functions will work together to repeat a message on the screen. The first function is called getNumber. It should have a return type of int and an empty parameter list. This function should prompt the user to enter a number, store that in a variable, and then return that variable. The second function is called getMessage. It should have a return type of string and an empty parameter list. This function should prompt the user to enter a message, store that in a variable, and then return that variable. The third function (procedure) is called repeat. It should have a void return type. This function requires two parameters: int num and string msg. In the body of the function, use a loop structure to display msg a total of num times to the screen. Lastly, in the main function, you should call your three functions in the appropriate order. Sample Run The following is an example of how your program should run: Enter a number: 6 Enter a message: Functions make programming easier! Functions make programming easier! Functions make programming easier! Functions make programming easier! Functions make programming easier! Functions make programming easier! Functions make programming easier! Part B - Function Prototypes For the second part of the lab activity, you will be practicing writing function prototypes. Continue working on the same project from part A. First, rewrite the code so that you are using function prototypes for the functions getNumber, getMessage, and repeat. Remember that the prototypes go at the top of the file, followed by main, then the definitions of the three functions at the end. Second, you will be creating a new function (procedure) called repeatTwo. It should have a void return type. Use the following prototype: void repeat Two (int, string, string); The function is similar to the repeat function. The difference is that, instead of repeating just one message, it's going to repeat two messages. You should use a different loop structure to handle this than the one you used for repeat. Third, you will need to modify the main function to give the user a choice of which repeating function to call. If the user wants the first version, then it should follow the same logic as in part A. But if the user chooses the second version (repeatTwo), then you will need to get an additional message from the user. Hence, you will need an extra function call to getMessage. The following is an example of how your program should run if just repeating once: Sample Run Enter 1 to repeat one message or enter 2 to repeat two messages: 1 Enter a number: 5 Enter a message: Same as part 1. Same as part 1. Same as part 1. Same as part 1. Same as part 1. Same as part 1. And if the user picks to repeat two messages: And if the user picks to repeat two messages: Enter 1 to repeat one message or enter 2 to repeat two messages: 2 Enter a number: 3 Enter a message: This one is different Enter a message: Functions!!! This one is different Functions!!! This one is different. Functions!!! This one is different Functions!!!

Step by Step Solution

3.39 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!