You have two separate problems. Approach them separately and independently:
- Get good input from user.
- Draw rectangle based on that input.
Part 1 - You must ask the user for input. You must check that input to see if it meets your requirements. If not, you should tell the user what he did wrong and give him a chance to enter it again. Hence the code where you ask for input must be inside some sort of loop, either a for-loop or a while loop. How many times will the user enter bad data? You have no idea, so the loop should be a while loop, not a for-loop.
Part 2 - Once you have good data, you need to draw the rectangle. There's more than one way of doing it. You can break it up into five stages.
- Print the top line.
- Print the lines that are not the top line, but are above the center line.
- Print the center line.
- Print the lines that are not the bottom line, but are below the center line.
- Print the bottom line.
Depending on how many lines there are, you may not need to do all of them. If the height is less than 5, you will not do all five steps. Do the steps that you need to do in order.
Within steps 2, 3, and 4, you'll be displaying different characters, so split it into sub-steps.
Breaking the larger task into these smaller tasks will make things more manageable.