The num1 variable remains = ans after stopping the current calculation can someone please help me out tried everything. New to C# could be missing something, you don't need to read past here trying to fill space it wont let me submit it without this . This is
static void Main(string[] args)
{
Boolean x;
x = true;
while (x == true)
{
double num1;
double ans;
double num2;
string cal;
Boolean y;
y = true;
Console.WriteLine("Enter a number ");
num1 = Convert.ToInt32(Console.ReadLine());
while (y == true)
{
Console.WriteLine("What calculation do you want to perform ");
cal = Console.ReadLine();
Console.WriteLine("Enter a number ");
num2 = Convert.ToInt32(Console.ReadLine());
switch (cal)
{
case "+":
ans = add(num1, num2);
Console.WriteLine("Answer " + ans);
num1 = ans;
break;
case "-":
ans = sub(num1, num2);
Console.WriteLine("Answer " + ans);
num1 = ans;
break;
case "/":
ans = div(num1, num2);
Console.WriteLine("Answer " + ans);
num1 = ans;
break;
case "*":
ans = mul(num1, num2);
Console.WriteLine("Answer " + ans);
num1 = ans;
break;
case "Stop":
y = false;
break;
}
}
}
}