Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You must run at least 3 assert based tests for every function and both phases each time main runs. Phase 1: Model the walk of

image text in transcribed

You must run at least 3 assert based tests for every function and both phases each time main runs. Phase 1: Model the walk of a sailor stumbling down a long pier toward a ship in the dark during a heavy rain and wind that randomly changes direction and speed. Prompt the user for the length and have your code set the width as a function of the length. Display the length and width. The sailor must start at the middle of the pier and take length steps to the ship. Each step moves the sailor 1 pace toward the ship and veers 1 pace to the left or right with equal probability. Use rand in a function to return LEFT if the random number is even or RIGHT if odd. You must NOT use polar coordinates in this assignment. After each step, print the step number and indicate how far left or right the walker is from center Use ASCII art to show the position of the sailor on the pier after each step (see partial example demo). OPTIONAL: indicate if the walker is wet or dry and on or off the pier After you get the above to work, repeat the walk at least 33 times in a loop, collect data for each repetition in vectors. After the repetitions are done, display the collected data vectors and their summary statistics over all 33 runs: at least: min, max, mean, median (OPTIONAL: mode). On the pier walk, how far left, right, or steps wet or dry. You must use the same set of functions to get statistics for any vector Phase 2 (add code to produce this work): Use a 2-dimensional random walk to model a sailor trying to reach the shoreline, under challenging weather conditions. Start at the middle (0, 0) of a perfectly circular island of a known radius. Prompt user for a radius; show it. In this case, for each step, the sailor takes 1 pace in any of several random directions, with equal probability, say, NORTH, SOUTH, EAST or WEST Use rand0 in a function to return one of those enum defined directions: for example, taking a pace to the: NORTH means the y-coordinate increments by 1, SOUTH means the y-coordinate decrements by 1 EAST means the x-coordinate increments by 1, WEST means the x-coordinate decrements by 1 After each step, display the step number, the current x and y coordinates followed by the current distance from the center (0, 0) as a double. Use the Pythagorean Theorem in a function. Stop this walk when the sailor has reached the shoreline. You must use Cartesian/rectangular (x.y), not polar, coordinates. Record each step in a square 2-D array and after each step, use ASCII art to show the position of the sailor and the island and all feasible past step numbers. Some steps may be covered by more recent ones; you must show, at least, the most recent step at each grid position. OPTIONAL: show each step direction. Repeat the island walk at least 33 times, collect data vectors and show summary statistics (steps taken to get wet, steps headed North, South, etc. Or any data that seems interesting) You must run at least 3 assert based tests for every function and both phases each time main runs. Phase 1: Model the walk of a sailor stumbling down a long pier toward a ship in the dark during a heavy rain and wind that randomly changes direction and speed. Prompt the user for the length and have your code set the width as a function of the length. Display the length and width. The sailor must start at the middle of the pier and take length steps to the ship. Each step moves the sailor 1 pace toward the ship and veers 1 pace to the left or right with equal probability. Use rand in a function to return LEFT if the random number is even or RIGHT if odd. You must NOT use polar coordinates in this assignment. After each step, print the step number and indicate how far left or right the walker is from center Use ASCII art to show the position of the sailor on the pier after each step (see partial example demo). OPTIONAL: indicate if the walker is wet or dry and on or off the pier After you get the above to work, repeat the walk at least 33 times in a loop, collect data for each repetition in vectors. After the repetitions are done, display the collected data vectors and their summary statistics over all 33 runs: at least: min, max, mean, median (OPTIONAL: mode). On the pier walk, how far left, right, or steps wet or dry. You must use the same set of functions to get statistics for any vector Phase 2 (add code to produce this work): Use a 2-dimensional random walk to model a sailor trying to reach the shoreline, under challenging weather conditions. Start at the middle (0, 0) of a perfectly circular island of a known radius. Prompt user for a radius; show it. In this case, for each step, the sailor takes 1 pace in any of several random directions, with equal probability, say, NORTH, SOUTH, EAST or WEST Use rand0 in a function to return one of those enum defined directions: for example, taking a pace to the: NORTH means the y-coordinate increments by 1, SOUTH means the y-coordinate decrements by 1 EAST means the x-coordinate increments by 1, WEST means the x-coordinate decrements by 1 After each step, display the step number, the current x and y coordinates followed by the current distance from the center (0, 0) as a double. Use the Pythagorean Theorem in a function. Stop this walk when the sailor has reached the shoreline. You must use Cartesian/rectangular (x.y), not polar, coordinates. Record each step in a square 2-D array and after each step, use ASCII art to show the position of the sailor and the island and all feasible past step numbers. Some steps may be covered by more recent ones; you must show, at least, the most recent step at each grid position. OPTIONAL: show each step direction. Repeat the island walk at least 33 times, collect data vectors and show summary statistics (steps taken to get wet, steps headed North, South, etc. Or any data that seems interesting)

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

Recommended Textbook for

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions

Question

LO3 Define the difference between job satisfaction and engagement.

Answered: 1 week ago