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...
-
Listing 2.7, ShowCurrentTime.java, gives a program that displays the current time in GMT. Revise the program so that it prompts the user to enter the time zone offset to GMT and displays the time in...
-
The collar has a weight of \(50 \mathrm{lb}\) and falls from rest down the titanium bar. If the bar has a diameter of 0.5 in., determine the maximum stress developed in the bar if the weight is (a)...
-
Kingsley Products, Ltd., is using a model 400 shaping machine to make one of its products. The company is expecting to have a large increase in demand for the product and is anxious to expand its...
-
A cart is pushed over a horizontal floor with 3 forces of equal magnitude of 4 N each. One of the forces points 35 degrees east of north, another points 35 degrees west of north, and a third force...
-
Enzo Franco was dismissed from employment at Precision Dynamics because of a race-related incident. Enzo sued Precision Dynamics for $150,000 because of the discrimination. Which of the following...
-
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...
-
Suppose that g(x) (x) h(x) for all x 2 and suppose that Can we conclude anything about the values of , g, and h at x = 2? Could (2) = 0? Could lim x2 (x) = 0? Give reasons for your answers. lim...
-
Marquis Company uses a weighted - average perpetual inventory system and has the following purchases and sales: Date Activities Units Acquired at Cost Units Sold at Retail August 2 Purchase 1 0 units...
-
Listed below are some identifying characteristics of organizations. Type a "X " in the appropriate column(s) to indicate which characteristics apply to each type of organization. Some characteristics...
-
What is biological extinction (extinction)? What is an endemic species and why are such species vulnerable to extinction? Define and distinguish between the background extinction rate and mass...
-
Question 4 On August 1, 2026, Bullock Company borrowed $27,000 from a bank on an 8%, 7-month note payable. Bullock Company borrowed $60,000 from a bank on February 1, 2027 on a 5%, 11-month note...
-
Shalit company uses job order cost system and has established a predetermined overhead application rate for the current year of 150% of direct labor cost,based on budgeted overhead of $1800000 and...
-
During a rehearsal, all eight members of the first violin section of an orchestra play a very soft passage. The sound intensity level at a certain point in the concert hall is 38.0 dB. What is the...
-
How do the principles of (a) Physical controls and (b) Documentation controls apply to cash disbursements?
-
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...
-
Excerpts from Andre Company's December 31, 2024 and 2023, financial statements are presented below: Accounts receivable Inventory Net sales Cost of goods sold Total assets Net income Total...
-
The York City Hospital has just acquired new equipment. The equipment cost $ 4 , 2 5 0 , 0 0 0 , and the organization spent $ 1 3 5 , 0 0 0 on upgrading the physical plant to the new equipment will...
-
Calculate the following showing all the necessary steps: Note: CPP rate to be used in the calculation is 5.95%. Note: Don't forget to deduct pay period exemption\ \ Tanya earns $25.00 per hour. This...
Study smarter with the SolutionInn App