1. ## Beginner Question

How do I fix this? I don't know how to convert inputted choice to equal the If statement.

Code:
```#include "stdafx.h"

#using <mscorlib.dll>

using namespace System;

int _tmain()
{
double cont = 1, r, theta, x, y, A, B;
__wchar_t choice;
while (cont == 1)
{
Console::Write( S"A	Convert Polar Coordinates to Cartesian \n");
Console::Write( S"B	Convert Cartesian Coordinates to Polar \n");
Console::Write( S"C	Determine Roots of a quadratic equation \n");

if ( choice == A)
{
Console::Write( S"R: ");
Console::WriteLine( S"Theta: ");
x = r * Math::Cos(theta);
y = r * Math::Sin(theta);
Console::Write( S"X: {0}", x.ToString());
Console::Write( S"Y: {0}", y.ToString());
return 0;
}
if ( choice == B)
{
Console::WriteLine( S"X: ");
Console::WriteLine( S"Y: ");
r = Math::Sqrt(Math::Pow(x, 2)+Math::Pow(y, 2));
theta = Math::Atan(y/x);
return 0;
}
}
}```

2. Methinks this is C#. This is a C++ forum. Mods, please move.

3. This is C++ with .net

4. Code:
```   if ( choice == __wchar_t('A'))
.
.
elseif ( choice == __wchar_t('B'))```

5. Oh, OK. My fault, I haven't used .NET in so long.

6. Originally Posted by swoopy
Code:
```   if ( choice == __wchar_t('A'))
.
.
elseif ( choice == __wchar_t('B'))```
Thanks for the help but, inputting A still doesn't bring up thing.

7. Nevermind it works. Thanks!

8. What does it mean when it says unreferenced local variable, (A and B)?

9. It means you didn't "use" A or B.
Code:
```  double cont = 1, r, theta, x, y, A, B;
__wchar_t choice;
while (cont == 1)
{
Console::Write( S"A     Convert Polar Coordinates to Cartesian \n");
Console::Write( S"B     Convert Cartesian Coordinates to Polar \n");
Console::Write( S"C     Determine Roots of a quadratic equation \n");

if ( choice == A)```
Maybe the compiler is warning you of this undefined behavior. Technically, the variable is referenced by the == operator, no? I don't know. Initialize your variables.

10. Hi, thanks for all the answers.. one more question

Code:
```   if ( choice == __wchar_t('A'))
{
Console::Write( S"R: ");
Console::Write( S"Degrees: ");
Console::WriteLine("");
Console::WriteLine( S"X: {0}", x.ToString());
Console::WriteLine( S"Y: {0}", y.ToString());
}```
Do you guys see anything wrong with this?
It seems to work fine until X or Y is suppose to equal 0.. it gives some e-16 value.

11. Hm. Your trig funtions are either returning terribly small numbers, or you're having floating point issues. To debug, every time a double is assigned, print out its value right afterwards to make sure things are what you expect them to be.

12. Everything is fine until:

Code:
```
Where it works except when rad is say PI..

13. How do you cut off a Double variable after say 2 digits?

14. >How do you cut off a Double variable after say 2 digits?
In standard C++, you can do this:
Code:
```#include <iostream>
#include <iomanip>

int main()
{
double num = 5.12345;

std::cout << std::setprecision(2) << std::fixed << num << '\n';
}```
I have no idea how to do it in .NET.

Also just so you know:
Code:
`   if ( choice == __wchar_t('A'))`
I'm not positive, but I believe you can write this as:
Code:
`   if ( choice == T('A'))`