Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

****Please only C/C++ syntax******* Write a function that prompts and reads from

ID: 3657835 • Letter: #

Question

****Please only C/C++ syntax******* Write a function that prompts and reads from the user the name of the rectangle or the word stop and validates this user input. The user will enter the name for a rectangle by typing the keyword rec followed by a single space and then the name, e.g., when the user enters rec john (this is valid input), the name of the rectangle will be assigned to john. Note that just typing john is invalid input. If the user types stop then this indicates that the user does not want to enter any more rectangles. This is valid input. The user is not allowed to input a name for a rectangle that is already used for a previously entered rectangle. This is invalid input. Any other input is also invalid. This function has a return type of bool and returns true only if the user input entered was valid. The function has ve input parameters. A string that holds the prompt that asks for the name of the rectangle. A string that holds an error message to display if the user types invalid input. A string that holds an error message to display if the user types a name that is already being used. A string that will pass back the user input, i.e. whatever the user entered. Lastly, a vector of rectangles, i.e. a list, containing all rectangles entered so far. Use this function in steps (ii) and (xi).

Explanation / Answer

Most of the notes in this reference conform to both C and C++. When a syntax distinction between C and C++ exists, it is explicitly noted. Some elements are listed under multiple categories, in which case all but the primary reference have listed with an @ sign. Flow Control If statement If-else statement Switch and case goto break continue Loops For loop While loop Do while loop Variables primitive variable declarations Non-const pointer declaration @Const Pointers vs. Const Pointer Data @References Functions Function declarations and prototypes Function definition Function call Pointers getting a memory address - primitive type getting a memory address - arrays getting a memory address - functions getting a memory address stored in a pointer dereferencing a pointer Const Pointers vs. Const Pointer Data References Typecasting C-style typecast static cast dynamic cast const cast reinterpret cast Truth and Falsehood True False Operators assignment comparison - equality Boolean Or Boolean And Boolean Not Bitwise And Bitwise Or Ternary Operator (?:) Structs basic struct declaration pointer to a struct declaration access element, basic dereferencing point to struct to access member Arrays basic array declarations accessing array elements C Preprocessor Directives #include #define #undef #if #ifdef #ifndef #error __FILE__ __LINE__ __DATE__ __TIME__ __TIMESTAMP__ pragma # macro operator ## macro operator