Question: EECE.2160: ECE Application Programming Fall 2017 Programming Assignment #4: The Drunken Sailor' Problem Due Monday, 10/16/17, 11:59:59 PM Input: Your input must be entered in

 EECE.2160: ECE Application Programming Fall 2017 Programming Assignment #4: The Drunken

EECE.2160: ECE Application Programming Fall 2017 Programming Assignment #4: The Drunken Sailor' Problem Due Monday, 10/16/17, 11:59:59 PM Input: Your input must be entered in the order listed below. All inputs are integers. Note that your program should prompt the user to enter each value and check that each input fits within the bounds descrbed below, as well as ensure there are no formatting errors 1. Introduction This assignment, which introduces the use of loops, solves the following problem: givenA a starting location in a city, how long does it take a "drunken sailor who randomly chooses his direction at each intersection to reach the city's border? You will read input values to set up the problem parameters, run several trials to determine an average number of steps for the salor to reach the border, and output the results. the systom time to seed the RNG otherwise, the user input is used. See Section 4, "Hints and Tips," for more details M and N, the number of blocks in the X (2S Ms 10) and Y planes (2 s Ns 10). respectively. This pair of values will be entered on the same line. . A starting position for the sailor, input as a pair of intogers (X.Y) This problem is an example of a "random walk" a succession of random steps that can model roal world probloms liko stock price fluctuation or molecules traveling through liquid. The approach is a simple approximation of a Monte Carlo experiment, in which repeated random samples are run to find a numerical result These values should simply be separated by a space (eg, 3 5). You should not format your input as an (XY) pair using parentheses and a comma (e.g. (3.5)) The sair must always start within te aty, so the starting coordinates are 2. Deliverables subject to the folloming bounds: 1 5X s (M-11. 15YS (N-1) Submit your source file by uploading it directly to your Dropbox folder. Ensure your source fie name is prog4-sailors. Youshould submit ont.the.c file. Failure to meet this specification will reduce your grade, as descibed in the grading guidelines. T, The number of trials to axecute (1sTs 10). . Output: As noted above, the program should print a prompt for each input See Section 5, Test Cases,' for examples of acceptable prompts. If an input does not fit within the bounds described, or the user enters an improperly formatted value, the program 3. Specifications Problem description: The city is organized as a set of M x N blocks. The sailor's position, which must always be an intersection or a point on the bordar, can be Section 4 for hints on bounds checking and error messages represented as a pair of coordinates (X, Y), where 0sXs M, and 0 s Y SN The example below shows a 4 x 3 city, with the sallor at position (3, 2) Yooord Once the user has successfuly input all values, the program executes each trial, starting at the point specified. At each step of a trial, your program generates a random number representing the direction the sailor moves and changes his position accordingly. Your program should print messages at the following points: Al the start of each trial, the program should print a message indicating the start of a new trial and the starting point being used North Direction South o Example: Trial 41 Start: 3 1 Wost East . For each step of each trial, the program shold print the diet on the sair moves and his new position. o Example: Northi 3 2 Xcoord 0 . At the end of each trial, the program should print the total number of steps takon during that trial At each step of a given trial, the sailor will randomly choose a direction and walk until he reaches the next intersection. A trial ends when the sailor reaches one of the borders. Note that each new trial always uses the same starting pcint city Once all trials are complete, the program should caloulate the average number of steps taken per trial and output that value o Exampler Average , ot stops over 5 triala: 3.2 Again, see Section 5 Test Cases for detailed examples of how your output should look EECE.2160: ECE Application Programming Fall 2017 Programming Assignment #4: The Drunken Sailor' Problem Due Monday, 10/16/17, 11:59:59 PM Input: Your input must be entered in the order listed below. All inputs are integers. Note that your program should prompt the user to enter each value and check that each input fits within the bounds descrbed below, as well as ensure there are no formatting errors 1. Introduction This assignment, which introduces the use of loops, solves the following problem: givenA a starting location in a city, how long does it take a "drunken sailor who randomly chooses his direction at each intersection to reach the city's border? You will read input values to set up the problem parameters, run several trials to determine an average number of steps for the salor to reach the border, and output the results. the systom time to seed the RNG otherwise, the user input is used. See Section 4, "Hints and Tips," for more details M and N, the number of blocks in the X (2S Ms 10) and Y planes (2 s Ns 10). respectively. This pair of values will be entered on the same line. . A starting position for the sailor, input as a pair of intogers (X.Y) This problem is an example of a "random walk" a succession of random steps that can model roal world probloms liko stock price fluctuation or molecules traveling through liquid. The approach is a simple approximation of a Monte Carlo experiment, in which repeated random samples are run to find a numerical result These values should simply be separated by a space (eg, 3 5). You should not format your input as an (XY) pair using parentheses and a comma (e.g. (3.5)) The sair must always start within te aty, so the starting coordinates are 2. Deliverables subject to the folloming bounds: 1 5X s (M-11. 15YS (N-1) Submit your source file by uploading it directly to your Dropbox folder. Ensure your source fie name is prog4-sailors. Youshould submit ont.the.c file. Failure to meet this specification will reduce your grade, as descibed in the grading guidelines. T, The number of trials to axecute (1sTs 10). . Output: As noted above, the program should print a prompt for each input See Section 5, Test Cases,' for examples of acceptable prompts. If an input does not fit within the bounds described, or the user enters an improperly formatted value, the program 3. Specifications Problem description: The city is organized as a set of M x N blocks. The sailor's position, which must always be an intersection or a point on the bordar, can be Section 4 for hints on bounds checking and error messages represented as a pair of coordinates (X, Y), where 0sXs M, and 0 s Y SN The example below shows a 4 x 3 city, with the sallor at position (3, 2) Yooord Once the user has successfuly input all values, the program executes each trial, starting at the point specified. At each step of a trial, your program generates a random number representing the direction the sailor moves and changes his position accordingly. Your program should print messages at the following points: Al the start of each trial, the program should print a message indicating the start of a new trial and the starting point being used North Direction South o Example: Trial 41 Start: 3 1 Wost East . For each step of each trial, the program shold print the diet on the sair moves and his new position. o Example: Northi 3 2 Xcoord 0 . At the end of each trial, the program should print the total number of steps takon during that trial At each step of a given trial, the sailor will randomly choose a direction and walk until he reaches the next intersection. A trial ends when the sailor reaches one of the borders. Note that each new trial always uses the same starting pcint city Once all trials are complete, the program should caloulate the average number of steps taken per trial and output that value o Exampler Average , ot stops over 5 triala: 3.2 Again, see Section 5 Test Cases for detailed examples of how your output should look

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!