/AreaCalculation

Practice creating methods to calculate areas for different shapes in C#

Primary LanguageC#

Objective

Create a C# console application that calculates the area of a circle, triangle, rectangle, and square.

What to remember

You will be making frequent commits as you work!

Make comments next to your code – explain what you are doing!

Remember to use proper naming conventions for variables and methods. Variables will use camelCasing and methods will use PascalCasing.

Step 1: Create Console Application

Create a console application in Visual Studio 2022 (purple icon).

Initialize the correct folder in the command line with Git.

Step 2: Create 4 Methods

Circle Area Method:

Create a method that calculates the area of a circle.

Use a parameter called radius of type double.

Look up the formula for each method and implement the logic in the scope.

You are encouraged to research online to find the formula.

Commit your work.

Triangle Area Method:

Create a method that calculates the area of a triangle.

Use 2 parameters called baseLength and height of type double.

Look up the formula for each method and implement the logic in the scope.

You are encouraged to research online to find the formula.

Commit your work.

Rectangle Area Method:

Create a method that calculates the area of a rectangle.

Use 2 parameters called length and width of type double.

Look up the formula for each method and implement the logic in the scope.

You are encouraged to research online to find the formula.

Commit your work.

Square Area Method:

Create a method that calculates the area of a square.

Use a variable called side of type double.

Look up the formula for each method and implement the logic in the scope.

You are encouraged to research online to find the formula.

Commit your work.

Step 3: Get User Input and Call the Correct Method

In your main method:

Get user input for your circle method. Then call your circle method.

Get user input for your triangle method. Then call your triangle method.

Get user input for your rectangle method. Then call your rectangle method.

Get user input for your square method. Then call your square method.

Step 4: Push your work to Github

Remember the git workflow to do this!

Note: You may need to reference the previous lesson to help you.

BONUS

Prompt the user to choose a shape.

Take their input and display the calculated area of the chosen shape.

Note: You may need to use a selection statement to do this which is a future lesson.