Hey everyone I am kind of stuck with these function. i am trying to work ahead to get stuff done faster and this is what my output is so far. I am stuck on the width part. I am not trying to have anyone do my assignment for me and the reason I put all the output is for future reference and to have everyone get a feel of my project. At the bottom I will display my instructions and my entire output should be:
Programmed by <your name>
Type a negative for the height to exit!
Enter the height: 7
Enter the width: 5
Enter the character to fill the rectangle with: +
- - - - -
:+++:
:+++: (By the way i am trying to make this figure even out in spacing)
:+++:
:+++:
:+++:
_ _ _ _ _
Enter the height at the first prompt and the width at the second!
Type a -1 for the first prompt to exit!
Enter the height: 1
Invalid: Height cannot be less than 3.
Type a negative height to exit! Try again!!!
Enter the height: 0
Invalid: Height cannot be less than 3.
Type a negative height to exit! Try again!!!
Enter the height: 5
Enter the width: 1
Invalid: Width cannot be less than 3.
Try Again!!!
Enter the width: -4
Invalid: Width cannot be less than 3.
Try Again!!!
Enter the width: 2
Invalid: Width cannot be less than 3.
Try Again!!!
Enter the width: 10
Enter the character to fill the rectangle with: @
_ _ _ _ _ _ _ _ _ _
:@@@@@@@@:
:@@@@@@@@:
:@@@@@@@@:
_ _ _ _ _ _ _ _ _ _
Enter the height at the first prompt and the width at the second!
Type a -1 for the first prompt to exit!
Enter the height: 1
Invalid: Height cannot be less than 3.
Type a negative height to exit! Try again!!!
Enter the height: -4
#include <iostream>
using namespace std;
double Get_Character();
double Get_Number();
void Draw_Rectangle();
void Draw_Top_Bottom();
void Draw_Middle();
int main()
{
cout << "Programmed by Bryan Kruep";
cout << endl << endl;
cout << "Type a negative for the height to exit!";
double cha, height = 0, width = 0;
cha = Get_Character();
while (cha != -1)
{
cha = Get_Character();
}
return 0;
}
double Get_Character()
{
double height;
cout << "\nEnter the height: ";
cin >> height;
cout << endl << "Enter the width: ";
cin >> width;
return (height);
}
Write a program that asks the user to type in the height and width of a rectangle. It also asks the user to type in a character in which to fill the rectangle. The program prints the top and bottom of the rectangle using a hyphen ("-") and the sides using a pipe ("|"). The interior of the rectangle will be filled with the character the user types. Because of the fill character, the height and width of the rectangle cannot be less than 3, because if it is less than three, there would be no place to fill. If the user types an invalid height or width, the program should tell them it is invalid and ask them to type it in again. The program should keep accepting heights and widths until the user types a negative number for the height.
You should use the following functions:
Draw_Rectangle – The height, width and character are passed into this function. It calls the functions Draw_Top_Bottom and Draw_Middle. Nothing is returned from this function.
Draw_Top_Bottom – This function accepts an integer as the formal parameter and draws the top (or bottom) of the rectangle. Nothing is returned from this function.
Draw_Middle – This function accepts the height, width and the filler character as the parameters and prints the rows of the rectangle. Nothing is returned from this function.
Get_Number – This function has a prompt (a string) passed into the function and asks the user to type what the prompt asks. The function returns the number that is typed in. It does not check for the negative number (that is done in main)
Get_Character – This function asks the user to type in the filler character and returns it.