You are missing the closing curly brace (}
) at the end of this loop.
foreach (string s in tokens)
{
if (double.TryParse(s, out oneNum))
{
nums.Add(oneNum);
}
else
{
Console.WriteLine("You have inputed invalid number, please try again!");
break;
}
Without that closing brace, all the following calculations are considered to be inside that loop! Since the code includes a call to Console.ReadLine()
, it looks like you’ve finished the calculations when you’ve only gone through the first iteration of the loop.
solved What can I do to make my program work?