Reputation: 49
After creating this code:
Console.WriteLine("Hello, and Welcome to Shell Bomber!\n");
Console.WriteLine("In this game you will calculate the distance\n");
Console.WriteLine("a shell will rise and travel along the ground ^_^\n");
Console.WriteLine("theta = ?"); // initial angle that you will ask for from the user
double theta = Double.Parse(Console.ReadLine());
Console.WriteLine("v_o = ?"); // initial velocity that you will ask for from the user
double v_o = Double.Parse(Console.ReadLine());
Console.WriteLine("Calculate v_ox"); //Calculate vox = v_ocos(theta
double v_ox = v_o * Math.Cos(theta); //Use the Math.Cos(theta) method
theta = theta * Math.PI / 180.0; // Converts from degrees to radians
Console.ReadLine();
Is the program automatically going to convert the value of double v_ox = v_o * Math.Cos(theta) to a value from the user's input of an angle for theta and an initial value? Because when I run it, the program is not calculating the value? Did I do something wrong or is that just how I made it work?
Upvotes: 0
Views: 191
Reputation: 57959
If you mean the program isn't showing you the value, it is because you never WriteLine()
the result.
Upvotes: 3
Reputation: 564831
You need to convert theta
into radians before you calculate v_ox.
Once you've done that, just write the value to the console:
Console.WriteLine("Calculate v_ox"); //Calculate vox = v_ocos(theta
theta = theta * Math.PI / 180.0; // Converts from degrees to radians
double v_ox = v_o * Math.Cos(theta); //Use the Math.Cos(theta) method
Console.WriteLine("v_ox == {0}", v_ox); // Show this, if you want to see the value
Console.ReadLine();
Upvotes: 3
Reputation: 49985
Are you just missing the line where you output the result to the console? Maybe something like this:
Console.WriteLine("The calculated value is: {0}", theta);
Upvotes: 1