我正在创建一个友好的人工智能,其名字是菲尔;),但我需要它能够做数学。我确实尝试过,也尝试过+=,但它不起作用。例如,如果我执行 1+1,而不是 2,则结果为 11。这是我的代码:
namespace Game
{
public static class Program
{
//commands
public static string enteredCommand;
public static string commanddomath = "doMath";
//Math command stuff
public static string MathOperation;
public static string FirstOperatorNumber;
public static string SecondOperatorNumber;
public static string FinalAwnser;
static void Main()
{
if (enteredCommand == "doMath")
{
Console.WriteLine("Ok");
Console.WriteLine("What Operation should I do?");
MathOperation = Console.ReadLine();
if (MathOperation == "+")
{
Console.WriteLine("Addition! Easy! What is the first number? ex. 6");
FirstOperatorNumber = Console.ReadLine();
Console.WriteLine("Ok, …
Run Code Online (Sandbox Code Playgroud)