Question: Please help with C programming In the Footsteps of Captain Flint If you have read the book Treasure Island by Robert Louis Stevenson, or have

Please help with C programming

Please help with C programming In the Footsteps of Captain Flint If

you have read the book Treasure Island by Robert Louis Stevenson, or

In the Footsteps of Captain Flint If you have read the book Treasure Island by Robert Louis Stevenson, or have seen one of the movies based on it, you may remember that Captain Flint hid his enormous treasure on an island in the Caribbean Sea. Stevenson wrote about the map of the Treasure Island left by Flint, but he did not reveal that Flint also provided step-by-step directions for getting from the Walrus's anchorage (that is, the spot where Flint anchored his ship, the Walrus) to the treasure. The directions are literally step-by-step; that is, Flint recorded every step on his way from the anchorage to the buried treasure Your task is to write a program for analyzing Flint's directions. Specifically, you should complete either Problem 5A or Problem 5B (but not both). The second problem is harder; if you solve it, you will get 5 bonus points Flint's Directions The directions are a string of lower-case letters, where each letter represents one step of Captain Flint. Every letter shows the direction of the respective step; it may be "n (north), "e (east), "s (south), or "w" (west). For example, the directions "nneess" mean that Flint walked two steps to the north, then two steps to the east, and then two steps to the south. The Treasure Island is a square, the size of which is 40 40 yards. The length of Flint's step is one yard. Flint anchored his ship and started his walk in the south-western corner of the island. We use the standard convention of showing North at the top of the map, which means that Flint started in the lower left corner of the square, as seen on the map. He remained within the island during his walk, which means that all points of his walk are to the north-east of the starting point, and he never got more than 40 steps to the north or more than 40 steps to the east from the starting point. Problem 5A (50 points) Implement a program that inputs Flint's directions and calculates the distance from the anchorage to the buried treasure, that is, the distance between the start and the end of Flint's walk, measured in yards Note that it calculates the straight-line distance, not the number of steps in the directions. For example, if the directions are nne ess", the distance is 2, To calculate the straight-line distance, the program should determine the vertical distance and the horizontal distance from the anchorage to the treasure, and then apply the Pythagorean formula: distance-square-root(vertical-distance vertical-distance horizontal-distance horizontal-distance) Input and output: Your program should input a string with Flint's directions and print the distance from the anchorage to the buried treasure, rounded to the nearest integer. The length of the input string is between 1 and 1,000. Every character of the string is a lower-case letter, which may be "n, e, s, or "w. The string does not include any other characters

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!