Area Calculator Write a program that takes a user\'s input (X) to find and displ
ID: 3643188 • Letter: A
Question
Area CalculatorWrite a program that takes a user's input (X) to find and display the area (A) for the following:
A square with sides X, where A = X^2
A circle with radius X, where A = 3.14 * X^2
An equilateral triangle with side X, where A = Sqrt(3)/4 * X^2
I want you to create and use the following value returning functions in your program:
AreaSquare(Side) As Float
Returns the area of the square as a float
AreaCircle(Radius) As Float
Returns the area of the circle as a float
AreaEqTriangle(Side) As Float
Returns the area of the equilateral triangle as a float
Before attempting this assignment, be sure you have completed all of this weeks textbook and course module readings, participated in the weekly conferences, and thoroughly understand the examples throughout the chapter.
Please save your pseudocode as plain text--this makes it easier for me to read and grade your code! Your deliverable for this homework is the pseudocode source code.
The functions in your program will return a float value to the calling module so you could use them like this:
a = AreaSquare(X)
or
Write "The area of the square is " + AreaSquare(X)
Your output should look similar to this:
Area Calculator
Enter the length of a side of a square: 10.5
The area of the square is 110.25
Enter the length of a radius of a circle: 9
The area of the circle is 254.34
Enter the length of a side of an equilateral triangle: 3.2
The area of the triangle is 4.34
Thank you for using the Area Calculator!
If you want, you can also use a "menu" to prompt the user for which function to perform. Just be sure to put it in a loop and offer a quit menu option as well if you choose to use the menu.
Explanation / Answer
you have not mentioned which language . i am assuming C
#include<iostream.h>
#include<conio.h>
float AreaSquare(float x)
{ float area ;
area = x*x;
return area ;
}
float AreaCircle(float x)
{ float area;
area = 3.14*x*x;
return area;
}
float AreaTrinagle(float x)
{ float area;
area = 0.866*x*x; // 3/4 = 0.866
return area;
}
void main()
{ float X,area;
int choice;
printf("Area Calculator Enter Required dimension :- ");
scanf("%f",&X);
printf("Area of Square is :- %f ", AreaSquare(X) );
printf("Area of circle is :- %f ", AreaCircle(X) );
printf("Area of trinagle is :- %f ",AreaTriangle(X) );
printf("Thank you for using area calculator ! ");
}
Hope this helps
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.