jloga4
5/19/2017 - 11:25 AM

Calculates and prints the area of a rectangle or triangle.

Calculates and prints the area of a rectangle or triangle.

Console.WriteLine("Enter 1 for a rectangle or 2 for a triangle: ");
int choice = int.Parse(Console.ReadLine());

Console.WriteLine("Enter the two values: ");
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());

double area = (double) (a * b) / choice;
Console.WriteLine("The area of your figure is " + area);

// Enter 1 for a rectangle or 2 for a triangle:
// 1
// Enter the two values:
// 5
// 5
// The area of your figure is 25

// Enter 1 for a rectangle or 2 for a triangle:
// 2
// Enter the two values:
// 5
// 5
// The area of your figure is 12.5