0

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?

3
  • 1
    What makes you think it's not calculating the value? Are you viewing it in debug mode? Commented Feb 3, 2010 at 2:02
  • 1
    This is effectively a duplicate of stackoverflow.com/questions/2189087/…. Commented Feb 3, 2010 at 2:06
  • Lucky for him, you can't get -ve rep here. Commented Feb 3, 2010 at 7:39

3 Answers 3

3

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(); 
Sign up to request clarification or add additional context in comments.

Comments

3

If you mean the program isn't showing you the value, it is because you never WriteLine() the result.

Comments

1

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);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.