Write a program in C:
Write a program in C:
- Ask the user for the amount of diesel loaded in the submarine.
- Asks the user for the magnitude (distance), in meters, and the heading, in degrees of the
navigation to way-point one.
- Decompose the
direction (North, West, South, or East are the only reliable headings on the sub’s
compass) of the x component and then the y component. The x component is the
magnitude multiplied by the cosine of the angle. The y component is the magnitude
multiplied by the sine of the angle. Determine compass direction depending on weather
the vector component is positive or negative.
- Calculate the amount of diesel spent to waypoint 1 and output it. Also output the
amount of diesel remaining. (The submarine has a fuel capacity of 175 metric tons of
diesel but was loaded with 1 ton in the example. The submarine spends 1 ton of diesel
per 51 miles traveled.)
- This step has to be repeated for another waypoint.
- Ask the user for the target bearing (0 to 25 degrees) and range (range in meters).
In the given question, you are asked to create a C program that performs the following tasks:
- Takes input for the amount of diesel loaded in a submarine.
- Accepts input for the magnitude and heading (direction) to waypoint one.
- Decomposes the vector into x and y components and determines compass directions for each component.
- Calculates and displays the diesel spent and remaining diesel based on a specific consumption rate.
- Provides the option to repeat these calculations for additional waypoints or targets.
Essentially, you're tasked with building a program that helps manage submarine navigation, fuel consumption, and target calculations based on user input
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images