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...
-
A Truck on a Drawbridge A loaded cement mixer drives onto an old drawbridge, where it stalls with its center of gravity three-quarters of the way across the span. The truck driver radios for help,...
-
In Example 8.4, choose methane and hydrogen as independent components. Derive relationships for the remaining components in terms of methane and hydrogen. Data From Example 8.4:- Construct the...
-
1. What methods did Smart USA use to test market the Smart Fortwo car among prospective customers? 2. What trends are influencing the market potential of the Smart Fortwo car? 3. How does Smart USA...
-
Discuss the impact of surface roughness and microstructuring on convective heat transfer in microchannels. How do these surface characteristics alter flow patterns and heat transfer coefficients ?
-
Dry Quick (DQ) is a medium-sized, private manufacturing company located near Timmins, Ontario. DQ has a June 30 year-end. Your firm, Poivre & Sel (P&S), has recently been appointed as auditors forDQ....
-
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...
-
Consider Example 70 and the data set in figure 13.7. (a) Make a plot of the residuals c, against the lilted values y,. Make a plot of the residuals c, against the temperature values v,. Do either of...
-
Discuss why system homogeneity is a desirable feature of network infrastructure models. How does homogeneity simplify the issues of configuration and maintenance? What limits have to be placed on...
-
AJ is paid $14.52 per hour to work. He is paid time-and-a-half for all hours over 8 hours worked on a given day. Find his total earnings for the week if he works the following hours: Monday Tuesday...
-
The present stockholders of XYZ Corporation are no longer the incorporators whose names appeared in the articles of incorporation. The present stockholders wanted that their names should appear in...
-
What is any example of how to explain the interaction between the sellers and the buyers for a particular resource based off of a current article from a credible newspaper or magazine that addresses...
-
What are the main factors that contribute to employee turnover, and how can organizations reduce it? Explain
-
Construct a variation of the algorithm described in Example 12 along with justifications of the steps used by the algorithm to find the smallest distance between two points if the distance between...
-
Sportique Boutique reported the following financial data for 2012 and 2011. Instructions(a) Calculate the current ratio for Sportique Boutique for 2012 and 2011.(b) Suppose that at the end of 2012,...
-
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...
-
A firm has 36.30 million shares of common stock outstanding at a price of $32.81 per share. The firm also has 492000.00 bonds outstanding with a current price of $1,089.00. The outstanding bonds have...
-
Commwest Bank owns $300 million of variable-rate notes yielding BBR plus 4 per cent. These loans are financed by $300 million of fixed-rate bonds costing 5 per cent.Northside Building Societyhas $300...
-
Mr. Smith enters into the long position in 5 S&P 500 futures contracts. His brokerage account requires an initial margin balance equal to 15% of the notional amount and a maintenance margin equal to...
Study smarter with the SolutionInn App