## Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

### Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

# Arithmetic Calculator challenge problem, I cant exit the program for some reason.

Hi, This is my code:

```using System;

namespace TreeHouse.Calculator
{
class Calculator
{
static void Main()
{
var totalResult = 0.0;

while(true)
{
try
{
var number = double.Parse(entry);
if(entry.ToLower() == "quit") {
break;

}

Console.WriteLine("Please enter an operation [+ - / * ]: ");
if(entry2.ToLower() == "quit") {
break;
}

var number2 = double.Parse(entry3);
if(entry3.ToLower() == "quit") {

break;
}

if(entry2 == "+")
{
totalResult = number + number2;
}

else if(entry2 == "-")
{
totalResult = number - number2;

}

else if(entry2 == "*")
{
totalResult = number * number2;

}
else if(entry2 == "/")
{
totalResult = number / number2;

}

Console.WriteLine("the result is: {0}", totalResult);

}

catch(FormatException) {
continue;

}

}

}

}

}
```

when i try to exit the program by typing 'quit', i get the messege from my exception, I checked alot of times and i can't find the problem why my 'if' statment are not working..

another problem i have is when i type a string or a number in a operator prompt it pass and in result the "final result" become 0.. any ideas how to fix this?

:D?

****** UPDATE ******

I somehow tried to get all this code outside the 'try' check

```using System;

namespace TreeHouse.Calculator
{
class Calculator
{
static void Main()
{
var totalResult = 0.0;
Console.WriteLine("what is your name? : ");
Console.WriteLine("Welcome to the program {0}!", name);

while(true)
{
if(entry.ToLower() == "quit") {
Console.WriteLine("Goodbye, {0}", name);
break;

}

Console.WriteLine("Please enter an operation [+ - / * ^ ]: ");
if(entry2.ToLower() == "quit") {
Console.WriteLine("Goodbye, {0}", name);
break;
}

if(entry3.ToLower() == "quit") {
Console.WriteLine("Goodbye, {0}", name);
break;
}

try
{
var number = double.Parse(entry);
var number2 = double.Parse(entry3);

if(entry2 == "+")
{
totalResult = number + number2;
}

else if(entry2 == "-")
{
totalResult = number - number2;

}

else if(entry2 == "*")
{
totalResult = number * number2;

}
else if(entry2 == "/")
{
totalResult = number / number2;

}

else {
totalResult = Math.Pow(number, number2);

}

Console.WriteLine("the result is: {0}", totalResult);

}

catch(FormatException) {
continue;

}

}

}

}

}
```

It's working now but i dont fully understand why i had to get this code outside of the "TRY" check.

and i still didnt fixed the other problem i mentioned before.

The reason are the following codes

```                   Console.WriteLine("Please Enter a number: ");
var number = double.Parse(entry);
if(entry.ToLower() == "quit") {
break;

}

//....