subject

4.12 program 4, part 3: the "drunken sailor" problem 1. introduction this assignment, which introduces the use of loops, solves the following problem: given 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 sailor to reach the border, and output the results. this problem is an example of a "random walk,"a succession of random steps that can model real world problems like 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. this assignment has been split into three parts to teach you how to build a large program in smaller pieces. doing so makes the program easier to develop and test--you can make sure each smaller piece works and then integrate the pieces together. in this lab, part 3, you wil integrate your solutions to parts 1 and 2 and add some additional code to allow for multiple trials. remember, in addition to submitting your code, you must complete the blackboard assignment "program 4 style assessment" to get all of the points for this program. you can complete this "assignment" by typing a short message indicating you submitted your code through the textbook ide in your blackboard submission, indicate which of the three parts of the program you have completed. if you plan to complete all three parts, do not submit to blackboard until all parts are done. 2. specification problem description the city is organized as a set of m x n blocks. the sailor's position, which mu ays be an intersection or a point on the border, can be represented as a pair of coordinates (x, y), where 0 s xs m, and 0s y sn. see figure1 in the figures document for an example of a 4 x 3 city with the sailor at position (3, 2). the figures document also contains a general flowchart for the overall program. you have written parts of the program in the prior two sections; the flowchart should give you some idea how to integrate those parts together. input specification the input specification is defined in section 4.10, which contains part 1 of this assignment. note that, unlike part 2 of the assignment, the city size and sailor's starting position should be based on user input, not on predefined values. output specification most of the output specification is defined in the prior 2 parts of the assignment (sections 4.10 and 4.11). your part 3 solution, however, must include the following changes. because your program can now contain multiple, trials, the "start" and "end" messages for each trial must include the trial number (for example, trial # 1 start : 1 1 or trial # 3 total steps : 7) after all trials are complete, your program should print the average number of steps across all trials (for example, average # of steps over 3 trials: 3.33) detailed test cases showing appropriate input prompts can be found starting on page 3 of the figures document. error checking the list of possible errors is defined, along with the program input specification, in section 4.10 3. hints multiple trials each trial takes the sailor back to the original starting position (based on user input) and starts over. doing so may require you to declare some additional variables you did not need in parts 1 or 2. some of those variables can be initialized once in the program, while others may need to be re-initialized at the start of each trial. flow chart as mentioned above, the figures document contains a general flowchart for the overall program. 4. grading rubric as with prior assignments, 40 points will be assigned for programming style and 60 points will be assigned for successfully passing the auto-graded test cases the style points will be based on all three parts of the program-you must use appropriate coding style such as including appropriate comments, indenting the main0 function body, and appropriate variable declarations. you must complete the blackboard assignment "program 4 style assessment" to earn any of these points. when assessing output correctness, this part of the assignment is worth 20 of the 60 total points. each test case has a different number of points assigned to it, as shown in submit mode. this section will be auto-graded, while i will assign the other 40 points after inspecting your program.

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:30, ghazanfarwaheed7967
Auniversity wants to install a client-server network. which feature do you think is important for them as they set up the network? sending email blocking multiple people to use the same file low security low set up cost limited access to files
Answers: 1
image
Computers and Technology, 22.06.2019 15:30, alexdub9649
What is a costume plot? why is it important to a film or theater production?
Answers: 2
image
Computers and Technology, 23.06.2019 18:50, ana7496
What is transmission control protocol/internet protocol (tcp/ip)? software that prevents direct communication between a sending and receiving computer and is used to monitor packets for security reasons a standard that specifies the format of data as well as the rules to be followed during transmission a simple network protocol that allows the transfer of files between two computers on the internet a standard internet protocol that provides the technical foundation for the public internet as well as for large numbers of private networks
Answers: 2
image
Computers and Technology, 24.06.2019 00:30, rustjallison9928
Asecurity policy is a a. set of guidlines b. set of transmission protocols c. written document d. set of rules based on standards and guidelines
Answers: 2
You know the right answer?
4.12 program 4, part 3: the "drunken sailor" problem 1. introduction this assignment, which introdu...

Questions in other subjects:

Konu
Mathematics, 07.12.2021 18:50