`
using System;
namespace BasicCalculator
{
class Program
{
static void Main()
{
MathsOperator();
}
static void MathsOperator()
{
string InpOne, InpTwo, ops;
InpOne = "Please enter your first number";
InpTwo = "Please enter your second number";
ops = "Please enter your operator";
Console.WriteLine("Welcome to my basic Calculator in C#");
Console.WriteLine(InpOne);
double num1 = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(InpTwo);
double num2 = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(ops);
string op = Console.ReadLine();
if (op == "+")
{
Console.WriteLine(num1 + num2);
}
else if (op == "-")
{
Console.WriteLine(num1 - num2);
}
else if (op == "*")
{
Console.WriteLine(num1 * num2);
}
else if(op == "/")
{
Console.WriteLine(num1 / num2);
}
else if (op == "%")
{
Console.WriteLine(num1 % num2);
}
else
{
Console.WriteLine("Invalid operator is found please enter the right operator");
}
}
}
}
`
Top comments (0)