So i am just trying to get started with coding in general and i was trying to make a calculator in C# and it does work but i cant enter 0.4 problems or go higher than 9 numbers otherwise my calculator gives me this error: Value was either too large or too small for an Int32.
I searched the problem up and got led to this website and people here were talking about using a string instead. I tried that but it told me i cant use the - operator or * operator.
I am sorry that im even asking this there is probarly a super simple solution but i hope someone can answer this question.
class Program
{
//Ints
public static int value1;
public static int value2;
public static int result;
public string input = Console.ReadLine();
static void Main(string[] args)
{
while (true)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"Choose your mathmetical operator: (A)dd (S)ubtract (M)ultiply");
if (Console.ReadLine() == "A")
{
Console.WriteLine("Enter 2 values.");
value1 = Convert.ToInt32(Console.ReadLine());
value2 = Convert.ToInt32(Console.ReadLine());
Add(value1, value2);
}
}
}
static void Add(int value1, int value2)
{
result = value1 + value2;
Console.WriteLine($"{result}");
Console.ReadLine();
Console.Clear();
result = 0;
value1 = 0;
value2 = 0;
}
static void Subtract(int value1, int value2)
{
result = value1 - value2;
Console.WriteLine($"{result}");
Console.ReadLine();
Console.Clear();
result = 0;
value1 = 0;
value2 = 0;
}
static void Multiply(int value1, int value2)
{
result = value1 * value2;
Console.WriteLine($"{result}");
Console.ReadLine();
Console.Clear();
result = 0;
value1 = 0;
value2 = 0;
}
}
}