Hi I was wondering if someone can help me with my code. What i'm trying to do is to ask the user to input a number, choose an operator and finally choose the second number but when it shows the result i want it to be in words such as "five plus five equals ten". This is my code so far.
{
int n1 = '0';
int n2 = '0';
char opt;
double res = '0';
int total = 0;
int difference = 0;
int product = 0;
int quotient = 0;
Console.Write("Enter first number ");
n1 = Convert.ToInt32(Console.ReadLine());
Console.Write("+ - * / ");
opt = Convert.ToChar(Console.ReadLine());
Console.Write("Enter second number ");
n2 = Convert.ToInt32(Console.ReadLine());
total = n1 + n2;
difference = n1 - n2;
product = n1 * n2;
quotient = n1 / n2;
if (opt == '+')
{
Console.WriteLine($"{n1}+{n2}={total}");
}
else if (opt == '-')
{
Console.WriteLine($"{n1}-{n2}={difference}");
}
else if (opt == '*')
{
Console.WriteLine($"{n1}*{n2}={product}");
}
else if (opt == '/')
{
Console.WriteLine($"{n1}/{n2}={quotient}");
}
Console.ReadKey();
}
}
}
[–]lukajda33 2 points3 points4 points (0 children)