Answer to Question #179140 in C++ for rosmira natasha

Question #179140

donut has two circle. outer circle and inner circle. calculate shaded area of donut. outer area minus area minus area of inner circle. ask user to insert radius then calculate area.


1
Expert's answer
2021-04-07T08:53:43-0400
#include <iostream>


using namespace std;
int main (){
	float outerCircleRadius=0;
	float innerCircleRadius=0;
	//Read the radius of the outer circle
	while(outerCircleRadius<=0){
		cout<<"Enter the radius of the outer circle: ";
		cin>>outerCircleRadius;
	}
	innerCircleRadius=outerCircleRadius+1;
	//Read the radius of the inner circle
	while(innerCircleRadius<=0 || innerCircleRadius>=outerCircleRadius){
		cout<<"Enter the radius of the inner circle: ";
		cin>>innerCircleRadius;
	}
	//Calculate the area of the outer circle
	float areaOuterCircle=3.14*outerCircleRadius*outerCircleRadius;
	//Calculate the area of the inner circle
	float areaInnerCircleRadius=3.14*innerCircleRadius*innerCircleRadius;
	//calculate shaded area of donut.  outer area minus area minus area of inner circle. 
	float donutArea=areaOuterCircle-areaInnerCircleRadius;
	cout<<"Shaded area of donut: "<<donutArea<<"\n\n";
	system("pause");
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS