subject

Copy the following code and run it. You should break it into the following 3 functions
getValidInput - which asks the user to enter the radius and then make sure that it is valid before returning it
circleCalculations - which uses the raius passed in to calculate both the area and the circumference. The area is returned
printResults - sets the fixed and precision and prints out the output

#include
#include
using namespace std;

const double PI = 3.14159;
int main()
{
int radius;
double area;
double circ;

cout << "Type a -1 for radius to exit" << endl;
cout << "Enter the radius: ";
cin >> radius;
while (radius >= 0)
{
circ = 2 * PI * radius;
area = PI * pow(radius, 2);

cout. setf(ios::fixed);
cout. precision(1);
cout << "A circle with radius " << radius << " has a circumference of "
<< circ << " and an area of " << area << endl << endl;

cout << "Enter the radius: ";
cin >> radius;
}
}
Sample Output

Type a -1 for radius to exit
Enter the radius: 5
A circle with radius 5 has a circumference of 31.4 and an area of 78.5

Enter the radius: -4
Radius cannot be negative - try again!!!
Enter the radius: -7
Radius cannot be negative - try again!!!
Enter the radius: 12
A circle with radius 12 has a circumference of 75.4 and an area of 452.4

Enter the radius: 7
A circle with radius 7 has a circumference of 44.0 and an area of 153.9

Enter the radius: -1

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 15:30
The idea that, for each pair of devices v and w, there’s a strict dichotomy between being “in range” or “out of range” is a simplified abstraction. more accurately, there’s a power decay function f (·) that specifies, for a pair of devices at distance δ, the signal strength f(δ) that they’ll be able to achieve on their wireless connection. (we’ll assume that f (δ) decreases with increasing δ.) we might want to build this into our notion of back-up sets as follows: among the k devices in the back-up set of v, there should be at least one that can be reached with very high signal strength, at least one other that can be reached with moderately high signal strength, and so forth. more concretely, we have values p1 ≥ p2 ≥ . . ≥ pk, so that if the back-up set for v consists of devices at distances d1≤d2≤≤dk,thenweshouldhavef(dj)≥pj foreachj. give an algorithm that determines whether it is possible to choose a back-up set for each device subject to this more detailed condition, still requiring that no device should appear in the back-up set of more than b other devices. again, the algorithm should output the back-up sets themselves, provided they can be found.\
Answers: 2
question
Computers and Technology, 24.06.2019 18:30
What is the local portion of the e-mail address below? [email protected] a.) @ b.) biz c.) gumchewer d.) twrigley
Answers: 1
question
Computers and Technology, 24.06.2019 23:00
What is a current gdp and what is a real gdp?
Answers: 1
question
Computers and Technology, 25.06.2019 02:30
One important thing in finding employment is to get your resume noticed and read.true or false
Answers: 2
You know the right answer?
Copy the following code and run it. You should break it into the following 3 functions
getVal...
Questions
question
Mathematics, 02.12.2020 16:20
question
English, 02.12.2020 16:20
question
Social Studies, 02.12.2020 16:20
question
Business, 02.12.2020 16:20
Questions on the website: 13722361