Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is a C++ problem. Please give full explanation and code in details. Thanks. A local rancher has asked you to help them come up
This is a C++ problem. Please give full explanation and code in details. Thanks.
A local rancher has asked you to help them come up with a plan for laying fencing on their property. They need you to print out a blueprint for how to lay the fencing where a ' represents a post, a represents a foot of fencing and a 'S represents a single no trespassing sign. Your task write a C++ program that prompts the user for input (solicit requirements from the rancher) and A) print out the fence blueprint and B) tells the farmer how many signs to order. Program must prompt for: totalPosts, feetBetweenPosts, and minimumFeetBetweenSigns Rules: 1. a Sign may NOT be adjacent to a post or ON a post. 2. for any section between two posts, the number of feet of fence laid+the width of any signs (s) set must be equal to the feetBetweenPosts. There can be no missing' feet between posts. There can be no 'extra' feet between posts. 3. The distance between signs is regulated by the minimumFeetBetweenSigns. If possible a sign must occur at every x minimumFeetBetweenSigns feet. If a sign cannot be located the minimum number, then the sign must be placed in the next allowable location. The width of every sign is 1 foot. No partial feet of fence may be laid. No partial signs may be set. All fence and signs is measured in whole feet. 4. 5. POSTS have a 0 foot width. Posts shall not cause the length of the fence to increase. 6. the first sign must be at least minFeetBetweenSigns from the initial post 7. minFeetBetweenSigns is the minimum needed feet of fence between signs. E -S-S-S-1 i. The feet between the first sign and the second sign is 2. a. : Example 1 (user input is underlined) How many posts do you want to use? How many feet between posts? What is the minimum distance between signs (in feet)? 2 I--S-l-Sl-Sl-S Total Signs: 4 Example 2 (user input is underlined) How many posts do you want to use? How many feet between posts? 10 What is the minimum distance between signs (in feet)? 16 Total Signs: 4 Example 3 (user input is underlined) How many posts do you want to use? 3 How many feet between posts? 20 What is the minimum distance between signs (in feet)? 60 Total Signs: 0 Tips: . You will need several loops and if statements o you will need to track exactly how far along the fence you have gone. Consider building a "string" and printing the string out at the end of the program; this will allow you to use "cout"s for debug statements Assumptions Assume that the fence in question does NOT form a circuit, and that is is composed of individual fence segments. Assume all inputs will be > 0 It is possible that no signs could be set. See example 3Step 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