Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help Must be written in C Write a program to build a force-trajectory calculator as follows: - Ask the user for the number of

Please help

Must be written in C

Write a program to build a force-trajectory calculator as follows:

- Ask the user for the number of waypoints to be entered. If less than 2 or greater than 20 then re-prompt the user until an acceptable number is entered, then create an array of doubles with six rows and twenty columns. ( do not let the user fill more columns than the accepted number of waypoints)

- Call function clean and pass the array with the number of rows to it. This function will zero the whole array.

- Display a menu by calling the function menu which will return a character being the user choice from options listed below. The menu option should work for both lower and upper case letters.

- For each option, if successfully selected, get the input, do the calculations, display the output, then display the menu again and ask for the menu option. The program should repeat until the user selects the exit program option.

- If an invalid menu option is entered, then the msg. Invalid option should be displayed and the program then redisplays the menu and prompts the user again for a choice.

Function prototypes: (must create and use all the listed functions)

- void clean(double cat[][20], int n);

- char menu(void);

- void xvector(double cat[][20], int n);

- void yvector(double cat[][20], int n);

- void xdirection(double cat[][20], int n);

- void ydirection(double cat[][20], int n);

- double drop(double dog, double mouse);

- double fuel(double cat[][20], int n);

- double zero_fuel(double cat[][20], int n);

Option x:

- Asks the user for the magnitude (distance), in meters and store it in the first row of the array, and the heading, in degrees and store it in the second row of the array, for the navigation to the next waypoint. The flight path towards the target can only be flown on East-West or North-South axis in order to stay perpendicular with the radar signals.

- Call function xvector and pass the array and number of rows to it. This function should populate the missing x-component of the vector in the third row. The x-component is the magnitude multiplied by the cosine of the angle.

- Call function xdirection and pass to it the array and number of rows. The function determines compass direction for the x component,depending on whether the vector component is positive or negative, and then populates the fifth row with the ASCII value of the upper case E or W depending on the direction.

- Call function yvector and pass the array and number of rows to it. This function should populate the missing y-component of the vector in the fourth row. The y-component is the magnitude multiplied by the sine of the angle.

- Call function ydirection and pass to it the array and number of rows. The function determines compass direction for the y component, depending on whether the vector component is positive or negative, and then populates the sixth row with the ASCII value of the upper case N or S depending on the direction.

Option d: Dropping a heavy metal ball from a plane.

- Ask the user for the plane speed and altitude in meters. If the plane altitude is less than 2000 meters, then display a message saying insufficient altitude and re-prompt the user for input until a valid input is entered. If the altitude is above 2000 meters, then call function drop to calculate the horizontal distance that the ball will travel forward after being dropped before it hits the ground. First you have to calculate the time it takes the ball to hit the ground from the provided altitude using ( h= * g * t * t) where h is altitude, g is 9.8, and t is the time to hit the ground. Then use the time to find out the forward distance traveled by ( v = d/ t) where v is the plane velocity, d is the distance, and t is time traveled. The function drop returns the forward (horizontal) distance.

- Output the horizontal distance in a formatted statement.

Option f: calculate fuel availability with initial fuel load of 10523 liters and constant fuel consumption at 0.57 km / liter.

- Call function fuel and pass to it the array and number of rows. The function should return the amount of available fuel after the total x and y distances traveled. ( hint: calculate the amount of fuel spent for the total x and y distances traveled first)

- Output the amount of available fuel.

Option W:

- Call function zero_fuel and pass to it the array and number of rows. This function should call function fuel and return the number of kilometers that the plane can travel on the available fuel.

- Output the number of kilometers that the plane can still fly.

Option V:

- Output the following information for each waypoint separated by a dotted line. Output the populated waypoints only, no zero values, as follows:

Waypoint #

Heading

Magnitude

Horizontal travel (distance and direction as East or West)

Vertical travel (distance and direction as North or South)

Fuel spent for the vertical and horizontal distances traveled for this waypoint.

Option B: Exit the program.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions