I'm an absolute beginner in programming, and Today I decided to put my knowledge to the test and create a basic c# calculator. I've Done it, but now I'm looking for ways to Make it more shorter and readible. If you Have any suggestions, please give them!
using System;
namespace lol
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hi! What is your name?");
string name = Console.ReadLine();
Console.WriteLine(name + " What do you wanna do");
Console.WriteLine("Type \"+\" for addition");
Console.WriteLine("Type \"-\" for subtraction");
Console.WriteLine("Type \"*\" for multiplication");
Console.WriteLine("Type \"/\" for division");
string operation = Console.ReadLine();
Console.Write("Now, Give me number one: ");
double num1 = Convert.ToDouble(Console.ReadLine());
Console.Write("Now give me number two: ");
double num2 = Convert.ToDouble(Console.ReadLine());
if (operation == "+")
{
Console.WriteLine(num1 + num2);
}
else if (operation == "-")
{
Console.WriteLine(num1 - num2);
}
else if (operation == "*")
{
Console.WriteLine(num1 * num2);
}
else
{
Console.WriteLine(num1 / num2);
}
}
}
}
lol
:-P btw, you write four times Type X for addition \$\endgroup\$