Выбор через Case - C#
Формулировка задачи:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3 { }
interface IEmployee
{
int Perimetr
{
get;
set;
}
int ploshad
{
get;
}
}
public class Employee : IEmployee
{
public static int A;
public static int B;
public static int alfa;
private int perimetr;
public int Perimetr
{
get
{
return perimetr;
}
set
{
perimetr = value;
}
}
private int Ploshad;
public int ploshad
{
get
{
return Ploshad;
}
}
public Employee() // constructor
{
Ploshad = (int)( A * B * Math.Sin((Math.PI/ 180) * alfa));
perimetr = (A + B) * 2;
}
}
class TestEmployee
{
static void Main()
{
Console.WriteLine("Выберите фигуру:\n1 - Параллелограмм\n2 - Прямоугольник\n3 - Ромб\n0 - Выход");
System.Console.Write("Введите первую сторону параллелограмма: ");
Employee.A = int.Parse(System.Console.ReadLine());
System.Console.Write("Введите вторую сторону параллелограмма: ");
Employee.B = int.Parse(System.Console.ReadLine());
System.Console.Write("Введите угол между двумя смежными сторонами ромба: ");
Employee.alfa = int.Parse(System.Console.ReadLine());
Employee e1 = new Employee();
System.Console.WriteLine("Расчёты:");
System.Console.WriteLine("Площадь: {0}", e1.ploshad);
System.Console.WriteLine("Периметр: {0}", e1.Perimetr);
Console.ReadLine();
}
}Решение задачи: «Выбор через Case»
textual
Листинг программы
string selection = ""