a.Write a program that finds the lengh of fence needed to enclose a circular gar
ID: 3643948 • Letter: A
Question
a.Write a program that finds the lengh of fence needed to enclose a circular garden and the area of the garden.Write it to accommodate three different gardens. Prompt the user for the radius of each circular garden and present the output information in tabular form. { setw() }Use all integer variable except for PI. (PI=3.1415)
e.g.
Radius(ft) Fence Lenght(ft) Garden Size(sg ft)
x xxxxxx xxxx
xx xxxxxx xxxx
xxx xxxxxx xxxx
b. Repeat part(a) except use all floating point variables. Output the information to one decimall place.
Circumference= 2*PI*radius
Area=PI*radius*radius
http://www.iimmgg.com/image/7005ffd617cc4f6d89491f95ad15e054 here is how it look like when it finished the left one is part a and the right one is part b please help me figure out the code. Thank in advance.
Explanation / Answer
Here ya go, hope this helps! This first program is the one using ints, the next program uses floats. #include #include using namespace std; //Define what PI is const float PI = 3.14150; //This represents a Garden struct Garden { int _radius; int getLenth() { return _radius*2*PI; } int getSize() { return _radius*_radius*PI; } }; int main() { Garden g1; Garden g2; Garden g3; cout > g1._radius; cout > g2._radius; cout > g3._radius; coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.