please it must be(( microsoft visual studio (2013)) if you dont have it do not d
ID: 3847161 • Letter: P
Question
please it must be(( microsoft visual studio (2013)) if you dont have it do not do it i have posted this question many times and they do not do it as requierd so please microsoft visual studio 2013 not 2012 not mac
Area Calculator
Write a program to calculate the area of some simple geometric shapes. The shapes required to be included are rectangles, circles, and right triangles. Because we have not covered conditional code yet, we will calculate all the shapes in order.
Your program must:
Ask the user for the values necessary to compute the area of each shape
oRectangle
o Circle
You must use an accurate value of pi (3.14159265359)
o Right Triangle
o The input must accept non-whole numbers
Display the results to the user
You do not need to attempt to make the program correct for improper input (e.g. negative numbers or non-numbers)
Area of a rectangle: What is the width of the rectangle 2.5 What is the height of the rectangle? 4.5 The area of the rectangle is: 11.25 Area of a circle: What is the radius of the circle? 3 The area of the circle is 28.2743 Area of a right triangle: What is the height of the triangle 16 What is the length of the base of the triangle? 6 The area of the rectangle is: 48Explanation / Answer
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double w,h,r,l;
cout<<"Area of a rectangle: "<<endl;
cout<<" What is the width of the rectangle? ";
cin >> w;
cout<<" What is the height of the rectangle? ";
cin >> h;
cout<<"The area of rectangle is "<<(w*h)<<endl<<endl;
cout<<"Area of a circle: "<<endl;
cout<<" What is the radius of the circle? ";
cin >> r;
cout<<"The area of circle is "<<(M_PI * r * r)<<endl<<endl;
cout<<"Area of a right triangle: "<<endl;
cout<<" What is the height of the triangle? ";
cin >> h;
cout<<" What is the length of the triangle? ";
cin >> l;
cout<<"The area of triangle is "<<(l*h)/2<<endl<<endl;
return 0;
}
Output:
sh-4.2$ g++ -o main *.cpp
sh-4.2$ main
Area of a rectangle:
What is the width of the rectangle? 2.5
What is the height of the rectangle? 4.5
The area of rectangle is 11.25
Area of a circle:
What is the radius of the circle? 3
The area of circle is 28.2743
Area of a right triangle:
What is the height of the triangle? 16
What is the length of the triangle? 6
The area of triangle is 48
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.