You're a programmer working for a large aerospace company. One of the aerospace engineers comes to you asking for help. "I would like a program to help me calculate the airspeed of an object when I know its speed and direction over the ground, and I know the speed and direction of the wind. For example, if an object is moving east (i.e. 90 degrees) at 10 mph and the wind is coming from the east (i.e. 90 degrees) at 5 mph, then the object is experiencing 15 mph of airspeed because it’s moving directly into the wind. When the wind is not directly in front or behind, though, trigonometry comes into play. The formula looks like this: Airspeed = (wind_speed * cosine (absolute_value(object_direction – wind_direction)) + object_speed Can you write me a program that asks me for object direction, object speed, wind direction, and wind speed which then calculates airspeed for me? Don’t forget that the wind direction is the direction the wind is coming from. I need it to do this over and over until I enter zeros for all of those things. I’d like the output to look like this:” (he draws the below on the whiteboard) Object direction: 90 Object speed: 10 Wind direction: 90 Wind speed: 5 Airspeed = 15 Object direction: 90 Object speed: 10 Wind direction: 70 Wind speed: 5 Airspeed = 14.6984631039295 Object direction: 0 Object speed: 0 Wind direction: 0 Wind speed: 0 You’ll need to use the Math.Cos and Math.Abs methods. You also need to convert the object direction and wind direction into radians since that’s what Math.Cos uses. Recall that you need to multiply your value in degrees by pi/180 (i.e. degrees * pi/180). Pi in C# is Math.PI so you don’t have worry about the actual 3.14159… number. All your variables should be declared as doubles. The following should help you get started (and is mirrored in the comments in the provided shell). -Declare your variables -Get user input -Convert object direction and wind direction to radians -Calculate airspeed using the above formula (don’t forget to take the absolute value of the direction subtraction) -Output the airspeed for the user -Get user input and stop when all zeros are entered
Question Attachments
0 attachments —