title: I am not sure how to convert degrees to radians for a variable in C#
body: <p>(Please keep in mind that I am new to coding so any glaring mistakes I apologize for in advance)</p>
  
  <p>I am currently trying to calculate the Flight time (and eventually distance) of a ballistics cannon using velocity and angle of the cannon provided by a user through the console.  However, the math is coming out wrong. The Tof calculation in comments was from an old line and am just using it for reference until everything works and I clean it up.  Since the current Tof is exactly what the equation requires:</p>
  
  <blockquote>
    <p>t = (v*sin(θ) + (v2sin2(θ) + 20*L*sin(θ))1/2 )/10 <em>where v is the
    velocity of the cannonball, θ is the angle to the ground, and L is the
    length of the cannon barrel.</em>)</p>
  </blockquote>
  
  <p>(except for the swap of sin^2(theta) to its Trig Identity), i believe the problem lies in the conversion from degrees to radians. The current line was something I assumed, since I have not been taught anything regarding that.  Any results online regarding the conversion give me something along the lines of:</p>
  
  <pre><code> private double DegreeToRadian(double angle)
  {
  return Math.PI * angle / 180.0;
  }
  </code></pre>
  
  <p>Which when it is put in the place of the current line, causes a ton of errors for almost everything beneath it.  I believe that chunk in meant to be a part of code on its own and not shoved into the middle of everything, but I do not know any other way to do this since all work must be done in the main method.<br>
  Any help is very much appreciated. The code in full is below:</p>
  
  <p>Edit1: this is when the above code is entered</p>
  
  <p>Edit2: the following changes were made: </p>
  
  <ol>
  <li>@pilotcam's suggestion to change everything to doubles</li>
  <li>@Shannon Holsinger's suggestion to change int.parse to double.parse</li>
  </ol>
  
  <p>@Shannon Holsinger - the first error is at the end of</p>
  
  <pre><code>double EnteredVelocityNum = double.Parse(EnteredVelocity);
  </code></pre>
  
  <p>Immediately after the semicolon.  It reads " } expected".</p>
  
  <p>@MethodMan - I am very sorry, but I do not understand your suggestion regarding: </p>
  
  <pre><code>double EnteredAngleNum = 0d;
  </code></pre>
  
  <p>Where do I put it?  I apologize again for my cluelessness, I have not learned this before and this is all rather new to me.</p>
  
  <pre><code>    using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
  
      namespace HW1
      {
      class Cannonball
      {
      static void Main(string[] args)
      {
  
              const double Length = 2;
  
              //here the velocity of the cannonball is acquired from the player
              string EnteredVelocity;
              Console.WriteLine("Enter the velocity of the cannonball betweeen 0-100 meters: ");
              EnteredVelocity = Console.ReadLine();
              Console.WriteLine("You entered: " + EnteredVelocity);
  
              // the angle of the cannon is acquired from the player
              string EnteredAngle;
              Console.WriteLine("Enter the angle of the cannon betweeen 0-90 degrees: ");
              EnteredAngle = Console.ReadLine();
              Console.WriteLine("You entered: " + EnteredAngle);
  
              //calculating the Time of Flight               
              double EnteredAngleNum = double.Parse(EnteredAngle);
              double EnteredVelocityNum = double.Parse(EnteredVelocity);
  
              private double EnteredAngleRad(double EnteredAngleNum)
                  {
                      return (Math.PI / 180) * EnteredAngleNum;
                  }
  
              //double EnteredAngleRad = (2 * Math.PI / 360) * EnteredAngleNum;
              //double ToF = Math.Pow(EnteredVelocityNum * Math.Sin(EnteredAngleRad) + (Math.Pow(EnteredVelocityNum,2)) * (Math.Pow(Math.Sin(EnteredAngleRad),2)) + 20 * Length * (Math.Sin(EnteredAngleRad)) , 0.5 ) / 10;  //This is trying to use Sin^2(theta) and gives 3.---
              double ToF = (EnteredVelocityNum * Math.Sin(EnteredAngleRad) + (Math.Pow((Math.Pow(EnteredVelocityNum, 2.0) * ((1.0 / 2.0) - ((1.0 / 2.0) * Math.Cos(2 * EnteredAngleRad))) + 20.0 * Length * (Math.Sin(EnteredAngleRad))), 0.5))) / 10.0; //This is trying to use Trig Identities and gives 4.06----
  
  
              Console.WriteLine("The Flight Time is: " + ToF);
              }
          }
      }
  </code></pre>