Question: Write a C++ program that uses programmr-defined functions to validate user input. Calculate some results and then print out a diamond patterned shape to the
You will first prompt the user to enter an odd integer between 1 and 19, inclusively. You will validate the user's input by creating a programmer-defined function to ensure that the integer is an odd integer in the range 1 to 19, inclusively. The integer entered by the user should be passed as a parameter to this function. If the number is not valid, you will display a meaningful error message before re-prompting the user to enter the integer again. The return type of this function should be a boolean data type and you are to use this boolean result in determining whether or not the user input is valid. You may assume that the user enters an integer, though it may be out of range Once validated, you will calculate and return the sum of the integers from 1 to the integer entered by the user using another programmer-defined function. Again, the integer entered by the user should be passed as a parameter to this function The return type of this function should be an integer data type and you are to use this integer result and print it to the screen in a meaningful message You will then prompt the user for and read in a printable character that will be used to draw the diamond. You may assume that the user enters a printable character Finally, you will draw the diamond using a programmer-defined function that accepts both the integer and the printable character entered by the user as parameters. The integer entered by the user will specify the number of rows in the diamond. You may only use cout statements that print a single character (i.e., that passed in by the user), a single space, or a single new-line character (such as ' or endl). Maximize your use of repetition with nested for loops and minimize the number of cout statements. This function should be a void function that does not return a value. It should print a diamond of the appropriate size using the printable character entered by the user. See the sample program run for an example of what should be output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
