COSC 1304 - Homework 2 You have been asked to construct a program that will draw
ID: 3645684 • Letter: C
Question
COSC 1304 - Homework 2 You have been asked to construct a program that will draw rectangular fences and compute the area they enclose. You will need to prompt the user for a width and a height value and then draw the rectangular fence on the screen with the dimensions they specify. You should compute and display the enclosed area and perimeter of the fence. Negative values are not allowed, so you should warn the user and prompt them for a new value. Zero is a valid value, and will cause the enclosed area to also be zero. The fence should be drawn using the plus (+), minus (-), and pipe (|) characters and enclose blank spaces. It should always draw the four corners (+). It should draw one horizontal segment (-) for each unit of width and a vertical segment (|) for each unit of height. Deliverables: Write a program in C using good style, indents, descriptive variable names, comments, etc.. Greet the user and provide one line about what the program is/does. Prompt the user for two values, width and height. Verify that the values are non-negative and prompt the user for new values as needed. Draw a rectangle on the screen using +, -, and | to the dimensions entered by the user. Compute and output to the screen the enclosed area and perimeter of the fence. Prompt the user to repeat with another fence and accept 'Y' and 'y' as valid responses to repeat. If the user does not wish to continue, exit the program with a closing message. Example Output: ----- Fence-o-matic ----- This program will draw and compute the area of a fence that you specify. Please enter a width: 4 Please enter a height: 3 +----+ | | | | | | +----+ Area = 12 Perimeter = 14 Would you like another fence? Y Please enter a width: 1 Please enter a height: 1 +-+ | | +-+ Area = 1 Perimeter = 4 Would you like another fence? Y Please enter a width: 2 Please enter a height: 0 +--+ +--+ Area = 0 Perimeter = 4 Would you like another fence? Y Please enter a width: -2 Negative numbers are not allowed! Please enter a width: 4 Please enter a height: -3 Negative numbers are not allowed! Please enter a height: 1 +----+ | | +----+ Area = 4 Perimeter = 10 Would you like another fence? N Thank you for using Fence-o-matic, GoodBye!Explanation / Answer
#include #include using namespace std; //Fence builder introduction void introFenceBuilding (){ coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.