Hello, I’m working on this task:
Write a program that first waits for the user to input two integers, A and B, one after the other, from the console. Then the user should input the operation “add” or “multiply”. If the user inputs “add”, output the sum of A and B. If the user answers “multiply”, output the multiplication product of A and B. For example:
>12
>3
>add
15
Here is my code:
namespace Booleans
{
public class ConsoleReadLine
{
public static void Main(string[] args)
{
string aString = Console.ReadLine();
string bString = Console.ReadLine();
int a = int.Parse(aString);
int b = int.Parse(bString);
string operation = Console.ReadLine();
Console.WriteLine(a);
Console.WriteLine(b);
Console.WriteLine(operation);
if(operation == "add")
{
Console.WriteLine(a + b);
}
else(operation == "multiply")
{
Console.WriteLine(a * b);
}
}
}
}
Can anyone please help me to solve it?