Question: IN C# Write a program that calculates and displays the area of a shape. In function main, the user is prompted to choose for which

IN C# Write a program that calculates and displays the area of a shape.
In function main, the user is prompted to choose for which
shape (circle, square or triangle) the area will be calculated.
Based on the user's shape selection, the program will call one of
three functions (circle, square or triangle) and the user is
then prompted for input of relevant dimensions.
For example, if circle is selected, the circle function is
called and the user is prompted for radius input.
The area calculation and dimensions input should be handled by whichever
of the three functions is called: circle, square or triangle.
The general template is given below, along with hints in the comments.
-----------------------------------------------------------------------*/
#include...
float circle();
float square();
float triangle();
int main()
{
return 0;
}
/*-------------------------------------------------------------------
FUNCTION: circle()
PURPOSE:
PARAMETERS:
RETURNS:
------------------------------------------------------------------------*/
float circle()
{
//1. create a variable for radius
//2. prompt for radius as user input
//3. save radius to the variable
return ...//4. calculate and return area as 3.14* R * R (or whatever you named your radius variable)
}
/*-------------------------------------------------------------------
FUNCTION: square()
PURPOSE:
PARAMETERS:
RETURNS:
------------------------------------------------------------------------*/
float square()
{
// follow the same plan as for circle, but prompt for side instead
// of radius and return area calculated as side * side
return ...
}
/*-------------------------------------------------------------------
FUNCTION: triangle()
PURPOSE:
PARAMETERS:
RETURNS:
------------------------------------------------------------------------*/
float triangle()
{
// area =0.5* base * height, so you will need to prompt for
// two variablas as user input and save each in a separate
// variable you already created
return ...
}
IN C# Write a program that calculates and

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!