Question: Code below was given. Need for it to be able to print out the following examples below. Show output after done. Thanks #include #include #include

Code below was given. Need for it to be able to print out the following examples below. Show output after done.
Thanks  Code below was given. Need for it to be able to
print out the following examples below. Show output after done. Thanks #include
#include #include //Global variables for loop indicies int i, j; //Get a
shape from a user, and return the shape if it is valid;
// otherwise, print an error message and terminate the program char getShapeFromUser(void);
//Get a length from a user, and return the length if it
#include
#include
#include
//Global variables for loop indicies
int i, j;
//Get a shape from a user, and return the shape if it is valid;
// otherwise, print an error message and terminate the program
char getShapeFromUser(void);
//Get a length from a user, and return the length if it is valid;
// otherwise, print an error message and terminate the program
int getLengthFromUser(void);
//Get a height from a user, and return the height if it is valid;
// otherwise, print an error message and terminate the program
int getHeightFromUser(void);
bool isShapeValid(char shape);
bool isLengthValid(int length);
bool isHeightValid(int height);
void drawRectangle(int length, int height);
void drawTriangle(int length);
void drawHexagon(int length);
void drawOctagon(int length);
void drawPentagon(int length);
//Do not modify the main function
int main(void){
char shape = getShapeFromUser();
int length = getLengthFromUser();
int height;
if(shape == 'r'){
height = getHeightFromUser();
printf("Below is a %d by %d rectangle of * ", length, height);
drawRectangle(length, height);
}
else if(shape == 't'){
printf("Below is a triangle with two side lengths of %d * ", length);
drawTriangle(length);
}
else if(shape == 'h'){
printf("Below is a hexagon with side lengths of %d * ", length);
drawHexagon(length);
}
else if(shape == 'o'){
printf("Below is an octagon with side lengths of %d * ", length);
drawOctagon(length);
}
else if(shape == 'p'){
printf("Below is a pentagon with 4 side lengths of %d * ", length);
drawPentagon(length);
}
return 0;
}
//Implement function prototypes below
char getShapeFromUser(void){
char shape = '\0';
printf("Enter a shape: r t h o p ");
scanf("%c", &shape);
if( !isShapeValid(shape) ){
printf("Invalid shape Goodbye! ");
exit(0);
}
return shape;
}
int getLengthFromUser(void){
int length = 0;
printf("Enter a length ");
scanf("%d", &length);
if( !isLengthValid(length) ){
printf("Length must be greater than 1 Goodbye! ");
exit(0);
}
return length;
}
int getHeightFromUser(void){
int height = 0;
printf("Enter a height ");
scanf("%d", &height);
if( !isHeightValid(height) ){
printf("Height must be greater than 1 Goodbye! ");
exit(0);
}
return height;
}

Project Submission After you have tested, tested, and retested that your code compiles and run correctly on many test cases (those provided in this document and test cases that you create on your own), submit the file proj3.c (and only that file) via our Canvas CPSC 101 l course website under this project's assignment (if you have any questions about how to submit your project, then you'll need ask your lab instructor days before the assignment is due). After you submit file(s) on Canvas for this program and other programs that you write this semester, always double check that you submitted the correct file(s) (to do this, download your submission from Canvas, view it, and make sure the submitted file(s) compiles and runs correctly on our Unix machines). Examples Your program should work correctly on the examples below, its source code should be compiled with the command aforementioned to produce an executable called proj3.out, and it should draw various shapes correctly when the inputs are valid (and output the messages shown in the examples below when it detects an invalid input). All input and output should be formatted as shown when run via the command line on our Unix machines (note: the new line(s) separating each example is not part of your program's I/O, it is in this document to show the difference between examples). Each example is separate run of a correctly working program. Some examples include invalid inputs, and some examples include Unix commands that provide alternative ways to input data into your program. ./proj out Enter a shape r t h o p Enter a length Enter a height Below is a 3 by 4 rectangle of Page 3

Step by Step Solution

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 Databases Questions!