Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is in C++ I don\'t understand how to get it to place multiple \"Fence Segme

ID: 3929645 • Letter: T

Question

This is in C++ I don't understand how to get it to place multiple "Fence Segments" (without using umpteen hundred switchs! and i feel like i'm supposed to do it in a different method since we haven't learned about switch's yet...)

Design a Program that will help fanner build an enclosed fence. This will be rectangular with the character | used for the North and South fence posts and mdash used for the boards, the East and West fence posts will use the - for the fence post and: for the boards between Will ask for North/South side fence posts and the number of East/West side fence posts number NO VALUES Less than 2 will be accepted as for these values (re-ask until a valid answer is given for each) Maximum number accepted is 10 for each if a value > 10 is entered do not re-ask just use the value of 10 A looping statement must be used for this program to be signed by the instructor. Continue to Build new fence pastures until the answer is an 'N' Inputs North_South posts 4 East_West posts 3 Response N The Sample Screen output should appear as follows adapted to inputs given 2016 Old Bruin Farm Fence Builder What is the Number of North/South Fence posts? Value must be at least 2 please What is the Number of North/South Fence posts? 4 What is the Number of East/West Fence posts? 3 Pasture Built!! Would you like to build another (Y/N)? N

Explanation / Answer

#include <iostream>
using namespace std;

int main()
{
   int ns,ew;
   char ch;
   while(true)
   {
       while(true)
       {
           cout<<"What is the Number of North/South Fence Posts?";
           cin>>ns;
           if(ns<2)
           {
               cout<<"Value must be atleast 2 please try again"<<endl;
               continue;
           }
           break;
       }
       while(true)
       {
           cout<<"What is the Number of East/West Fence Posts?";
           cin>>ew;
           if(ew<2)
           {
               cout<<"Value must be atleast 2 please try again"<<endl;
               continue;
           }
           break;
       }
       for(int i=0;i<ns-1;i++)
       {
           cout<<"|==";
       }
       cout<<"| ";

       for(int i=0;i<ew-2;i++)
       {
           cout<<":";
           for(int j=0;j<3*ns-4;j++)
           {
               cout<<" ";
           }
           cout<<": ";
           cout<<"-";
           for(int j=0;j<3*ns-4;j++)
           {
               cout<<" ";
           }
           cout<<"- ";
      
       }
       cout<<":";
       for(int j=0;j<3*ns-4;j++)
       {
           cout<<" ";
       }
       cout<<": ";
       for(int i=0;i<ns-1;i++)
       {
           cout<<"|==";
       }
       cout<<"| ";

       cout<<"Would you like to build another (Y/N)?";
       cin>>ch;
       if(ch=='N')
       {
           break;
       }
   }
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote