C# Coding Assignment Visual Studio (MUST USE THE ATTACHED SHELL).
You’re a programmer working for a large aerospace company. One of the aerospace engineers comes to you asking for help in setting up some data that is needed for a simulation. They have a vehicle that flies through the air and knows what direction its moving in, but can only measure its speed in reference to the ground. The engineers always know the direction and speed of the wind when their vehicle is flying because they can measure it from a ground station. They want to know the speed of the vehicle as it moves through the air. If this seems like a hard concept to grasp, that’s ok – the engineers have provided you with the following equation to calculate airspeed:
airspeed = (windSpeed * cosine(absoluteValue(vehicleDirection – windDirection)) + vehicleSpeed
The engineers give you the following vehicle speeds and directions:
Vehicle speeds: 1, 3, 5, 11, 16, 18, 22, 26, 30, 34
Vehicle directions: 10, 30, 50, 110, 160, 185, 260, 280, 315, 330
They want you to come up with a random value of wind speed between 10 and 30 along with a random value of wind direction between 0 and 359 for each of the 10 vehicle speed and direction pairs (i.e. at vehicle speed 1, it is moving in direction 10). Then they want to see the airspeed calculation based on those four numbers. You should output a table that looks like this (negative airspeeds are allowed):
NOTE: Your Wind Speed, Wind Direction, and Airspeed values will probably be different since your Wind Speed and Wind Direction values will be random!
You will need a total of five arrays. These all need to be of type double! Two of those arrays will be created as initialized arrays using the given vehicle speeds and vehicle directions (which you can conveniently copy and paste into your code). The other three will be created using an arraycreation expression as shown in slide 10 of this week’s PowerPoint.
To fill your wind speed and wind direction arrays you will need to use a for loop and the .Length property of one of those arrays (all the arrays are the same size, so it doesn’t matter – however, you have to use .Length in case you change the array size later). Since your wind speeds and directions need to be random, you need to look in your text (page 252, section 7.8) to see how to use the Random class. This means you’ll need two Random number generators – 1 each for wind speed and direction, and both combining “shifting” and “scaling” (see 7.8.5).
You will also need to use a for loop to calculate and fill the airspeed array using the equation above.
Outputting your final table will also require a for loop. Again, make sure you’re using the .Length property of one of your arrays so that you don’t go out of bounds.
Some hints to help get you started. You’ll need to use some methods from the Math library: Math.Cos and Math.Abs. Also, the vehicle directions are given in degrees, while Math.Cos takes a number in radians. This means you’ll have to convert from degrees to radians, but don’t worry it’s a simple conversion. Radians = degrees * (Pi / 180). C# makes this easy by providing you with Math.PI, so somewhere in your code you need to convert the vehicle direction and wind directions into radians. It might look like this: windRadians = windDirection * (Math.PI / 180); As a reminder – your output table should still show the degree values NOT the radian values.
There are several ways to accomplish this task, but here is one algorithm that might help:
Declare your variables
Fill the wind speed and wind direction arrays with the appropriate random values
Convert your vehicle direction and wind direction values to radians
Calculate airspeed values
Output the table
The provided shell also has these steps.
MUST USE SHELL BELOW AS A GUIDE:
//Name
//Data
//Assignment
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace assignment8
{
class assignment8
{
static void Main(string[] args)
{
//Declare your variables and arrays here – remember,
//you’ll need the arrays to be “double” and two of them
//should be initialized with the given values
//Fill your wind direction and wind speed arrays with random
//values based on the specifications given using a for loop
//Convert your vehicle and wind directions to radians – you can
//actually do this as part of the airspeed calculation if you like.
//Calculate airspeed values (also in a for loop) using the
//discussed Math library functions and property.
//Output your table (again, using a for loop)
}
}
}

ShellforAssignment8.docx
C# Coding Assignment Visual Studio (MUST USE THE ATTACHED SHELL)