I need please answer to this question, please .. . . Write a complete program th
ID: 3546497 • Letter: I
Question
I need please answer to this question, please ..
.
.
Write a complete program that draws two different filled shapes: square and rectangle. You have to implement two functions: one to draw square shape and the other to draw rectangle shape. The user will decide the dimensions of the shape. You have to use functions' prototypes and functions' overloading. Also, you have to draw the filled shapes using loops.
Sample output:
....
Welcome to my shapes!
Please select a shape to draw:
1- Square
2- Rectangle
3- Exit program
Your choice: 1
Please enter height or width of the square: 3
***
***
***
Please select a shape to draw:
1- Square
2- Rectangle
3- Exit program
Your choice: 2
Please enter height of the rectangle: 3
Please enter width of the rectangle: 2
**
**
**
Please select a shape to draw:
1- Square
2- Rectangle
3- Exit program
Your choice: 3
Explanation / Answer
#include<iostream>
using namespace std;
void draw(int l,int b);
void draw(int s);
int main()
{
int choice;
cout<<"Welcome to My Shapes"<<endl;
cout<<"Which Shape ypou want to be drawn"<<endl;
cout<<"1. Rectangular 2. Square"<<endl;
cin>>choice;
if (choice==1)
{
int l,b;
cout<<"Enter length of rectangle"<<endl;
cin>>l;
cout<<"Enter width of rectangle"<<endl;
cin>>b;
draw(l,b);
}
else if (choice==2)
{
int s;
cout<<"Enter side of square"<<endl;
cin>>s;
draw(s);
}
else
cout<<"Wrong input,Try again"<<endl;
return 0;
}
void draw(int l,int b)
{
for(int i=0;i<b;i++)
{
for(int j=0;j<l;j++)
cout<<"*";
cout<<endl;
}
}
void draw(int s)
{
for(int i=0;i<s;i++)
{
for(int j=0;j<s;j++)
cout<<"*";
cout<<endl;
}
}