Given the above shape, ask the user for the height and the width of the above re
ID: 3628131 • Letter: G
Question
Given the above shape, ask the user for the height and the width of the above rectangle. Calculate the area for half the rectangle, the area for the half circle and the area for the entire shape.
Requirement:
1) Use cin to grab the height
2) Use scanf to grab the width
3) Use a single printf statement to display the area for half the rectangle, the half circle and the total for the entire shape
4) Use a single cout statement to display the area of half the rectangle, the half circle and the total for the entire shape
Note: All the areas will have to be calculated based on only the information that was inputted by the user (Height and width of the rectangle)
Explanation / Answer
please rate - thanks
you didn't show the shape, so can't do accurate calculations
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{double height,width,area,areac;
cout<<"Enter the height of the rectangle: ";
cin>>height;
cout<<"Enter the width of the rectangle: ";
scanf("%lf",&width);
area=(height*width)/2.; //didn't show shape, so don't know
//areac=3.14*
areac=1; //didn't show shape, so don't know
printf("area of half the rectangle %f area of half the circle %f area of the shape %f ",
area,areac,area+areac);
cout<<"area of half the rectangle "<<area<<" area of half the circle "<<areac<<
" area of the shape "<<area+areac<<" ";
system("pause");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.