Проект 8: switch
double area;
double radius;
double length;
double width;
double base;
double height;
Console.WriteLine("Which shape do you want to find the area of?");
Console.WriteLine("1) Circle");
Console.WriteLine("2) Triangle");
Console.WriteLine("3) Rectangle");
userInput = Console.ReadLine();
switch (userInput)
{
case 1:
areaCircle();
break;
case 2:
areaTriangle();
break;
case 3:
areaRectangle();
break;
default
break;
}
areaCircle()
{
Console.Write("Input radius of the Circle: ");
radius = Console.ReadLine()
area = Math.PI() * Math.Pow(radius,2);
Console.WriteLine("The area of the Circle is : " + area);
}
areaTriangle()
{
Console.Write("Input base of the Triangle: ");
base = Console.ReadLine()
Console.Write("Input height of the Triangle: ");
height = Console.ReadLine()
area = 0.5 * base * height;
Console.WriteLine("The area of the Triangle is : " + area);
}
areaRectagle()
{
Console.Write("Input length of the Rectangle: ");
length = Console.ReadLine()
Console.Write("Input width of the Rectangle: ");
width = Console.ReadLine()
area = length * width;
Console.WriteLine("The area of the Rectangle is : " + area);
}
