Modify Listing 11.15 so that instead of reporting the results of a single trial for a particular
Question:
Modify Listing 11.15 so that instead of reporting the results of a single trial for a particular target/step combination, it reports the highest, lowest, and average number of steps for N trials, where N is an integer entered by the user.
Transcribed Image Text:
Listing 11.15 randwalk.cpp
// randwalk.cpp
// compile with the vect.cpp file
#include
Listing 11.15 randwalk.cpp
// randwalk.cpp
// compile with the vect.cpp file
#include
#include
#include
#include "vect.h"
int main()
{
}
using the Vector class
using namespace std;
using VECTOR::Vector;
srand(time (0));
double direction;
Tector step;
Vector result (0.0, 0.0);
unsigned long steps = 0;
double target;
double dstep;
// rand (), srand() prototypes
// time () prototype
cout << "Enter target distance (q to quit): ;
while (cin >> target)
{
// seed random-number generator
cout << "Enter step length: ";
if (! (cin >> dstep))
break;
while (result.magval() < target)
{
direction rand() & 360;
step.reset (dstep, direction, Vector::POL);
result result + step;
steps++;
}
cout << "After " << steps << " steps, the subject
"has the following location: \n";
cout << result << endl;
result.polar_mode ();
cout << or\n" << result << endl;
cout << "Average outward distance per step
<< result.magval() /steps << endl;
}
cout << "Bye!\n";
cin.clear();
return 0;
steps = 0;
result.reset (0.0, 0.0);
cout << "Enter target distance (q to quit): ";
while (cin.get () != '\n')
continue;
11
11
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 62% (16 reviews)
include include include include include vecth using namespace std using VECTORVector int main srandt...View the full answer
Answered By
Dansteve Matoke
As a consequence of more than three years of experience in ACADEMIC WRITING, I have vast, diverse knowledge and impeccable grammar. I guarantee the quality of my work across multiple fields. I intend to precisely meet the clients' expectations. Let's work together to achieve exceptional grades.
0.00
0 Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
The numbers in parentheses when reporting the results of a between-subjects, one-way ANOVA in APA format are ____ and ____.
-
The headline reporting the results of a poll conducted by the Gallup organization stated Majority of Americans at Personal Best in the Morning. The results indicated that a survey of 1100 Americans...
-
Reports of results from clinical trials often include statistics about baseline characteristics, so we can see that different groups have the same basic characteristics. Refer to Data Set 1 in...
-
On April 1 of the current taxable year, Mr. Lasing Gho died leaving Php 25, 000, 000 of net distributable estate. He also left behind Tessie, his legitimate wife; Rhealyn, his legally adopted...
-
What would be the effect of each of the following on the money demand, M1 (with other things held equal) ? a. An increase in real GDP b. An increase in the price level c. A rise in the interest rate...
-
Summarize the key advantages of stored procedures.
-
Why are priority rules needed? LO.1
-
Stanley Furniture Company is a Virginia-based furniture manufacturer. For each of the following firstyear transactions, indicate whether net cash inflows (outflows) from operating activities (NCFO),...
-
on november 1 the company renter space to another tenant
-
Q1) Draw the axial force, shear force and bending moment diagrams for the given beam. 5 KN SKN. SEN 2 lN/m 3 m Q2) Draw the axial force, shear force and bending moment diagrams for the given beam BH....
-
Consider the following variation of the Stack class defined in Listing 10.10: // stack.h -- class declaration for the stack ADT typedef unsigned long Item; class Stack { private: enum {MAX = 10}; //...
-
Modify Listing 11.15 so that it writes the successive locations of the random walker into a file. Label each position with the step number. Also have the program write the initial conditions (target...
-
Repeat Problem 14.6 for a depth of 3.50 in. Repeat Problem Compute the hydraulic radius for the section shown in Fig. 14.19 if water flows at a depth of 2.0 in. The section is that of a rain gutter...
-
1. [-/1 Points] DETAILS Find the associated exponential decay or growth model. (Round all coefficients to three significant digits.) Q=3,000 when t = 0; doubling time = 4 Q = Need Help? Read It Watch...
-
The 10 m wide gate restrains water at a depth of 6 m. Calculate the magnitude of the hinge reaction at A, and the contact force between the gate and the smooth surface B. Neglect the weight of the...
-
Write a program loop, using a pointer and a counter, that dears i'o 0 the contents of hexadecimal locations 500 through 5FF. Write a program to multiply two positive numbers by a repeated addition...
-
entries. Record journal entries in the order presented in the problem. If no entry is required, select "No Entry" for the account titles and enter O for the amounts. Credit account titles are...
-
APA formatting : Take the information below and put it into correct APA format. Journal Article (5 points) Authors: William R. Johnson, Cynthia E. Hernandez, Jamal M. Wilson. Year published: 2019....
-
Graph the function. (x) = log 1/3 (3 - x)
-
Some people argue that the internal control requirements of the Sarbanes-Oxley Act (SOX) put U.S. companies at a competitive disadvantage to companies outside the United States. Discuss the...
-
At which positions of a heap might the largest key be stored?
-
Give an example of a worst-case sequence with n elements for insertion-sort, and show that insertion-sort runs in (n 2 ) time on such a sequence.
-
The min method for the UnsortedPriorityQueue class executes in O(n) time, as analyzed in Table 9.2. Give a simple modification to the class so that min runs in O(1) time. Explain any necessary...
-
Which of the following statements regarding traditional cost accounting systems is false? a. Products are often over or under cost in traditional cost accounting systems. b. Most traditional cost...
-
Bart is a college student. Since his plan is to get a job immediately after graduation, he determines that he will need about $250,000 in life insurance to provide for his future wife and children...
-
Reporting Financial Statement Effects of Bond Transactions (please show me how you got the answers) Lundholm, Inc., which reports financial statements each December 31, is authorized to issue...
Study smarter with the SolutionInn App