keep looping after finish calculation

If you’re seeking for a completely newbie solution, you may want to raise a flag on successful operation, and wrap operator input into another loop:

bool successful;
do
{
    string uservalue = Console.ReadLine();
    if (uservalue == "*")
    {
        Result = a * b;
        Console.Write("Resultat= " + a * b);
        successful = true;
    }
    //other operators
    else
        Console.WriteLine("put right operator !!!");
} while (!successful)

Also I would recommend switch/case sonstruction, like that:

string uservalue = Console.ReadLine();
switch (uservalue)
{
    case "*":
        Console.Write("Resultat= " + (a * b));
        break;
    //other operators
    default:
        Console.WriteLine("put right operator !!!");
        break;
}

P.S.: you’re calculating your values twice, once when assigning a value to the variable “Result”, and second one when outputting a string, if you already have the value in your variable, you should call Console.Write("Resultat= " + Result);

Leave a Comment