Как добавить факториал в нужное поле? - C#
Формулировка задачи:
когда начинаю пихать программы при любых её вариациях выдаёт ошибку на строчке;
собственно с неё и начинается код этого блока
вот исходник:
static void Factorial_calculation()
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HelloOperators_stud
{
class Program
{
static void Main(string[] args)
{
long a;
Console.WriteLine(@"Please, type the number:
1. Farmer, wolf, goat and cabbage puzzle
2. Console calculator
3. Factirial calculation
");
a = long.Parse(Console.ReadLine());
switch (a)
{
case 1:
Farmer_puzzle();
Console.WriteLine("");
break;
case 2:
Calculator();
Console.WriteLine("");
break;
case 3:
Factorial_calculation();
Console.WriteLine("");
break;
default:
Console.WriteLine("Exit");
break;
}
Console.WriteLine("Press any key");
Console.ReadLine();
}
private static void Factorial_calculation()
{
throw new NotImplementedException();
}
#region farmer
static void Farmer_puzzle()
{
}
#endregion
#region calculator
static void Calculator()
{
while (true)
{
{
double X1, X2;
string _operator;
Console.WriteLine("введите первое число: ");
X1 = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("введите знак:+ или - или / или * или ^ ");
_operator = Console.ReadLine();
Console.WriteLine("Введите второе число: ");
X2 = Convert.ToDouble(Console.ReadLine());
switch (_operator)
{
case "+":
Console.WriteLine("otvet");
Console.WriteLine(X1 + X2);
break;
case "-":
Console.WriteLine("otvet");
Console.WriteLine(X1 - X2);
break;
case "*":
Console.WriteLine("otvet");
Console.WriteLine(X1 * X2);
break;
case "/":
Console.WriteLine("otvet");
Console.WriteLine(X1 / X2);
break;
case "^":
Console.WriteLine("otvet");
Console.WriteLine(Math.Pow(X1, X2));
break;
}
}
#endregion
}
#region Factorial
{
[COLOR="Red"]<=сюда впихнуть код[/COLOR]
}
#endregion
}
}
}Решение задачи: «Как добавить факториал в нужное поле?»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HelloOperators_stud
{
class Program
{
static void Main(string[] args)
{
long a;
Console.WriteLine(@"Please, type the number:
1. Farmer, wolf, goat and cabbage puzzle
2. Console calculator
3. Factirial calculation
");
a = long.Parse(Console.ReadLine());
switch (a)
{
case 1:
Farmer_puzzle();
Console.WriteLine("");
break;
case 2:
Calculator();
Console.WriteLine("");
break;
case 3:
Factorial_calculation();
Console.WriteLine("");
break;
default:
Console.WriteLine("Exit");
break;
}
Console.WriteLine("Press any key");
Console.ReadLine();
}
#region farmer
static void Farmer_puzzle()
{
}
#endregion
#region calculator
static void Calculator()
{
while (true)
{
{
double X1, X2;
string _operator;
Console.WriteLine("введите первое число: ");
X1 = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("введите знак:+ или - или / или * или ^ ");
_operator = Console.ReadLine();
Console.WriteLine("Введите второе число: ");
X2 = Convert.ToDouble(Console.ReadLine());
switch (_operator)
{
case "+":
Console.WriteLine("otvet");
Console.WriteLine(X1 + X2);
break;
case "-":
Console.WriteLine("otvet");
Console.WriteLine(X1 - X2);
break;
case "*":
Console.WriteLine("otvet");
Console.WriteLine(X1 * X2);
break;
case "/":
Console.WriteLine("otvet");
Console.WriteLine(X1 / X2);
break;
case "^":
Console.WriteLine("otvet");
Console.WriteLine(Math.Pow(X1, X2));
break;
}
}
}
}
#endregion
#region Factorial
static void Factorial_calculation()
{
// <=сюда впихнут код[/COLOR]
}
#endregion
}
}