<Your Name and G Number>
// CS 262, Lab Section <Lab Section Number>
// Lab 3
Your code must contain at least one of all of the following control types:
a for() loop
a while() or a do-while() loop
a switch() statement
an if-else statement
Consider which control structures will work best for which aspect of the assignment.
The first thing your program will do is print a menu of choices for the user. (Hint: Which control type given above will work best for a menu?) You may choose your own version of the wording or order of choices presented, but each choice given in the menu must match the following:
|Menu Choice||Valid User Input Choices|
|Enter/Change Character||‘C’ or ‘c’|
|Enter/Change Number||‘N’ or ‘n’|
|Print Triangle Type 1 (Left Justified)||‘1’|
|Print Triangle Type 2 (Right Justified)||‘2’|
|Quit Program||‘Q’ or ‘q’|
A prompt is presented to the user to enter a choice from the menu. If the user enters a choice that is not a valid input, a message stating the choice is invalid is displayed and the menu is displayed again.
Your executable file will be named Lab3_<username>_<labsection>
Your program must have at least four functions (not including main()) including:
A function that prompts the user to enter a single character. The return value of the function be a char and will return the character value entered by the user. This return value will be stored in a local variable, C, in main(). The initial default value of this character will be ‘ ‘ (blank or space character).
A function that prompts the user to enter a numerical value between 1 and 15 (inclusive). If the user enters a value outside this range, the user is prompted to re-enter a value until a proper value is entered. The return value of the function be an int and will return the value entered by the user. This return value will be stored in a local variable, N, in main(). The initial default value of this character will be 0.
Two “Print Triangle” functions. Each function will take the previously entered integer value N and character value C as input parameters (You will need to ensure that these values are valid before entering these functions). The return values of these functions will be void. The functions will print triangles of N lines containing the input character C. The Left Justified function will print the triangle with the characters Left-Justified. The Right Justified function will print the triangles with the characters “Right-Justified.” For example, if the integer value N = 6, and the character value C = ‘*’ and the Right Justified Triangle type is called, the following triangle will be printed:
If the Left-Justified triangle is to be printed, then the following triangle is printed:
Suggested Steps to Complete the Assignment:
You are not required to complete the following steps to write your program or even pay attention to them. However, if you do decide to use the suggested steps, you should test your program thoroughly to ensure each step works correctly before moving on to the next step.