Question
I'm having trouble getting my program to print shapes For example: Which shape (L-line, T-triangle, R-rectangle): L Enter an integer length between 1 and 25:
I'm having trouble getting my program to print shapes
For example:
Which shape (L-line, T-triangle, R-rectangle): L Enter an integer length between 1 and 25: 13 *************
Which shape (L-line, T-triangle, R-rectangle): t Enter an integer base length between 3 and 25: 5 * ** *** **** *****
Which shape (L-line, T-triangle, R-rectangle): r Enter an integer width and height between 2 and 25: 4 5 **** **** **** **** ****
Here's my code:
#include
#include
const int MAX_DIMENSION = 25;
void printLine(int length){
scanf("%d", &length);
for(int i=0; i if(length<0 && length>25){ printf("That input is invalid."); else{ printf("*"); } } } } void printTriangle(int baseLength){ scanf("%d", &baseLength); for(int i=0; i if(length<3 && length>25){ printf("That input is invalid."); else{ printf("*"); } } } } void printRectangle(int width, int height){ scanf("%d %d", &width, &height); for(int i=0; i for(int j=0; j if((width<2 && width>25) && (height<2 && height>25){ printf("That input is invalid."); else{ printf("*"); } } } } } int main() { char option; printf("Which shape (L-line, T-triangle, R-rectangle): "); scanf("%c", &option); option = toupper(option); printf(" "); switch (option) { case 'L' || case 'l': printf("Enter an Integer length between 1 and 25"); printLine(); break; case 'T' || case 't': printf("Enter an Integer base length between 3 and 25"); printTriangle(); break; case 'R'|| case 'r': printf("Enter an Integer width and height between 2 and 25"); printRectangle(); break; default: break; } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started