title: C++ Program to Simulate Kepler's Equations
body: <p>So I am trying to make a basic C++ program that calculates the mean, eccentric, and true anomalies as well as the radial distance and velocity of a planet. This is one of my first programs I have worked on, so I know it's not as concise as it could be. I'm just having a hard time getting it to run. I know some of the values might need to be converted to make the units match up, and I can do that later. I just want to know what is causing it not to run. Also in main, I have if statements for every planet; I didn't include the rest because it would just take up too much space. </p>
  
  <p>Ultimately, the goal of the program is to print a table of times, the anomalies, r, and v given the planet name. If you need any clarification, please let me know. Thank you</p>
  
  <p>Thanks in advance</p>
  
  <pre><code>const float G = 6.673E-11;
  const float solar_m = 1.989E30;
  const float mu = G*solar_m;
  
  class Planet
  {
    double a, ec, T;
  public:
    void SetValues(float, float, float);
    float Calculations();
  };
  
  void Planet::SetValues(float m_a, float m_ec, float m_T)
  {
    m_a = a;
    m_ec = ec;
    m_T = T;
  }
  
  float Planet::Calculations()
  {
    //Set up values
    a = a*1.496E11; //AU to m
    T = T*365;   //Period converted to days
  
    float delta = 0.001;
  
    float M;
    float E;
  
    float E1;
    float E2, f_E2;
    float E3, f_E3;
  
    float f,r,v;
  
    for(int t; t&lt;T; t++)
      {
        M= sqrt(mu/(a*a*a))*t;
        E1= M;
  
        E2 = (M-E1+ec*sin(E1))/(ec*cos(E1)-1);
        f_E2 = M-E2+ec*sin(E2);
  
        E3 = (M-E2+ec*sin(E2))/(ec*cos(E2)-1);
        f_E2 = M-E3+ec*sin(E3);
  
        if (f_E2&lt;delta)
          E=E2;
        else if (f_E3&lt;delta)
          E=E3;
        else
          cout&lt;&lt;"not enough iterations";
  
        f = 2*atan(sqrt((1+ec)/(1-ec))*tan(E/2));
        r = (a*(1-ec*ec))/(1+ec*cos(f));
        v = sqrt(mu*(2/r -1/a));
  
        cout&lt;&lt; t&lt;&lt;"     "&lt;&lt;M&lt;&lt;" "&lt;&lt;E&lt;&lt;" "&lt;&lt;f&lt;&lt;" "&lt;&lt;r&lt;&lt;" "&lt;&lt;v;
      }
  };
  
  int main()
  {
    int i;
    float t;
    string pName;
    cout&lt;&lt;"What planet do you want to simulate?";
    cin&gt;&gt;pName;
  
    if (pName.compare("mercury") || pName.compare("Mercury"))
      {
        Planet me;
        me.SetValues(.387, .2056, .24);
        me.Calculations();
      };
  </code></pre>