Question

Help C++ Design a program for determining how much a fence will cost based on the...

Help C++

Design a program for determining how much a fence will cost based on the size of a residents back yard. Luckily, every resident has a square backyard with side lengths of at least 6 feet. Unfortunately, there is a local zoning requirement that all fences must be exactly 2 feet inside the perimeter of a backyard. The local fence construction company will charge 10 dollars per foot of fence.

Based on the description above design a program that will take the length of a side of a residents backyard (in feet) as in input and then output the amount of dollars that such a fence will cost

. --Note-- You will not be required to write any cout statements asking the user for input. You will simply write the code and place your input(s) into the "Enter program input (optional)" text box recalling that multiple inputs are separated by a space

#include <iostream>
using namespace std;

int main()
{
cout << " Enter side of fence: " << endl;
float side;
float perimeter;
float cost;
cin>>side;
perimeter = side * 4;
cost = perimeter * 10;
cout << "\n For side of " << side << "feet, length of fence is " << perimeter << "feet" ;
cout<< "\n Cost of fencing = " << cost <<" dollars";
return 0;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>
using namespace std;

int main()
{
    cout << "Enter side length of backyard: " << endl;
    float side;
    float perimeter;
    float cost;
    cin >> side;
    side -= 4;  // because fencing must be 2 feet inside from perimeter of backyard on all sides.
    perimeter = side * 4;
    cost = perimeter * 10;
    cout << "\n For fencing side of " << side << " feet, length of fence is " << perimeter << " feet" ;
    cout<< "\n Cost of fencing = " << cost <<" dollars";
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
Help C++ Design a program for determining how much a fence will cost based on the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • How do I do this? Using c++ 7.4 Practice Problem Set 1 Q3 You live in...

    How do I do this? Using c++ 7.4 Practice Problem Set 1 Q3 You live in squareville. Everyone in squareville wants a fence around their backyard, but they are having trouble figuring out how much a fence will cost. The mayor of squareville has hired you to design a program for determining how much a fence will cost based on the size of a residents back yard. Luckily, every resident has a square backyard with side lengths of at least...

  • please explain in C++ only This program determines how much it cost to paint a room...

    please explain in C++ only This program determines how much it cost to paint a room Please write a program which determines and prints out three results. 1. The number of exact gallons of paint to paint the walls and the ceiling (NOT THE FLOOR) of the room if 1 gallon is enough to paint 400 square feet. 2. How many gallons of paint you need to buy since you cannot buy part of a gallon. So if you need...

  • Please help me to write a program in C++ with comments and to keep it simple...

    Please help me to write a program in C++ with comments and to keep it simple as possible. Thank you! Here is my program I have done before and that need to be change: #include <iostream> #include <iomanip> using namespace std; // function prototype – returning one value double cylvol(double, double); // Note: two data types inside brackets double surfarea(double, double); // Note: two data types inside brackets int main() { double r, l, V, S; cout << setprecision(2) <<...

  • C Language <stdio.h> (FUNCTIONS) A concrete company wants to estimate what it will cost a customer...

    C Language <stdio.h> (FUNCTIONS) A concrete company wants to estimate what it will cost a customer to have a driveway poured. They can pour a 3 inch deep 200 sq. ft. driveway in 3 hours, and they charge $50.00 per hour as their labor rate. Write a program to ask the user for the length of the driveway (in feet), and the width of the driveway (in feet) to be poured. For both the length and width, make sure the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT