static float GetFloatValueFromUser(string promptMessage){
Console.Write(promptMessage);
bool isFloatConverted = float.TryParse(Console.ReadLine(), out initAngle);
Console.WriteLine("Invalid Initial Angle!");
GetFloatValueFromUser(promptMessage);
static double DegreeToRadian(float angle)
return Math.PI * angle / 180.00;
public static void Main()
Console.WriteLine("Welcome! ");
Console.WriteLine("This application will calculate the maximum height of the shell and "+
"the distance. It will travel along the ground.");
Console.WriteLine("==================================================================================================================");
Console.WriteLine("Please provide following inputs: ");
float theta = (float)DegreeToRadian(GetFloatValueFromUser("Initial Angle: "));
float speed = GetFloatValueFromUser("Speed: ");
float vox = speed * (float)Math.Cos(theta);
float voy = speed * (float)Math.Sin(theta);
double h = voy * voy / (2 * g);
Console.WriteLine("Height of shell at apex is {0} meters", h.ToString("n3"));
Console.WriteLine("Distance shell travels horizontally is {0} meters (assuming launch and target elevations are equal)", dx.ToString("n3"));