The Drunkard’s (Random) Walk. Imagine you live on an infinite grid of streets where locations are...

The Drunkard’s (Random) Walk. Imagine you live on an infinite grid of streets where locations are represented as integer pairs (avenue,street). Negative numbers are okay in this example. Now consider a drunkard that randomly picks one of four directions at an intersection and then stumbles to the next intersection doing the same and so on. Write a class Drunkard to simulate this behavior given the drunkard’s initial position. Your Drunkard class should have as instance variables the drunkard’s current avenue (x location) and current street (y location). Your class should have a method called step( ) that moves the drunkard to the next randomly chosen adjacent intersection. Your class should have another method called fastForward(int steps) that takes an integer as a parameter (call it steps) and moves the drunkard steps intersections from his current location. Your class should have a method getLocation( ) that returns a String indicating the drunkard’s current location. Finally your class should have a method called howFar( ) that reports the drunkards distance in blocks from where he started calculated using the Manhattan distance metric.

You will find a test class called DrunkardTester below. Your Drunkard class must work with the test class provided without modification. You must NOT alter the test class.

DrunkardTester.java :

/**
* A tester for the Drunkard class.
*/

import java.util.Scanner;

public class DrunkardTester {
public static void main(String[] args) {

   Scanner input = new Scanner(System.in);

   System.out.println("Please enter the starting avenue integer: ");
   int avenue = input.nextInt();
   System.out.println("Please enter the starting street integer: ");
   int street = input.nextInt();
  
   // make the Drunkard with initial position
   Drunkard ozzy = new Drunkard(avenue,street);

   // have him move 100 intersections
   ozzy.fastForward(100);
  
   // get his current location
   String location = ozzy.getLocation();
  
   // get distance from start
   int distance = ozzy.howFar();

   System.out.println("Current location: " + location);
   System.out.println("That's " + distance + " blocks from start.");

}
}

Additionally, there is a completely empty Drunkard.java file that you must fill out.

(Your code goes here...)

Note that the definition of Manhattan distance is:

“The distance between two points in a grid based on a strictly horizontal and/or vertical path (that is, along the grid lines), as opposed to the diagonal or “as the crow flies” distance. The Manhattan distance is the simple sum of the horizontal and vertical components, whereas the diagonal distance might be computed by applying the Pythagorean theorem.”

In: Computer Science

Problem 13-15 The Ashland Company recently hired you to review its control procedures for the purchase,...

Problem 13-15 The Ashland Company recently hired you to review its control procedures for the purchase, receipt, storage, and issuance of raw materials. You prepared the following comments, which describe Ashland’s procedures. Raw materials, which consist mainly of high-cost electronic components, are kept in a locked storeroom. Storeroom personnel include a supervisor and four clerks. All are well trained, competent, and adequately bonded. Raw materials are removed from the storeroom only upon written or oral authorization from one of the production foremen. There are no perpetual inventory records; hence, the storeroom clerks do not keep records of goods received or issued. To compensate for the lack of perpetual records, a physical inventory count is taken monthly by the storeroom clerks, who are well supervised. Appropriate procedures are followed in making the inventory count. After the physical count, the storeroom supervisor matches quantities counted against a predetermined reorder level. If the count for a given part is below the reorder level, the supervisor enters the part number on a materials requisition list and sends this list to the accounts payable clerk. The accounts payable clerk prepares a purchase order for a predetermined reorder quantity for each part and mails the purchase order to the vendor from whom the part was last purchased. When ordered materials arrive at Ashland, they are received by the storeroom clerks. The clerks count the merchandise and see that the counts agree with the shipper’s bill of lading. All vendors’ bills of lading are initialed, dated, and filed in the storeroom to serve as receiving reports. a. List the internal control weaknesses in Ashland’s procedures. b. For each weakness that you identified, recommend an improvement(s).

In: Accounting

A transformer contains four times as many turns in the secondary coil as it does in...

A transformer contains four times as many turns in the secondary coil as it does in the primary coil. If the input voltage is 4000 V, what is the output voltage?

1000 V

2000 V

4000 V

8000 V

16000 V

In: Physics

The C5H5+ and C5Cl5+ cations, which have never been isolated, are known to be ground state...

The C5H5+ and C5Cl5+ cations, which have never been isolated, are known to be ground state triplets - that is, they have 2 unpaired electrons, thus are diradicals. But the C5(CH3)5+ cation has no unpaired electrons - it is a singlet.

Construct a schematic molecular diagram of C5H5+ (pi system only) in D5h point group using pz-orbitals of C. Sketch the shape of each orbital next to the irreducible representation of the MO. Does your MO diagram support the singlet or triplet ground state?

Result from X-ray crystallography, NMR, and theory..... C5(CH3)5+ is an irregular pentagon.... the ring is nonplanar... the pi electrons are found to be largely localized on opposite sides of the ring - in an allyl cation fragment and in a double bond.

Now, construct a schematic molecular diagram of C5(CH3)5+ (pi system only) using px-orbitals of C, assuming allyl group and a double bond separately and simply put them on the same stack). Sketch the shape of each orbital next to the irreducible representation of the MO. Does your MO diagram support the singlet or triplet ground state?

Please help!! Super hard homework question!

In: Chemistry

A gymnast of mass 62.0kg hangs from a vertical rope attached to the ceiling. You can...

A gymnast of mass 62.0kg hangs from a vertical rope attached to the ceiling. You can ignore the weight of the rope and assume that the rope does not stretch. Use the value 9.81m/s2 for the acceleration of gravity.

Calculate the tension T in the rope if the gymnast hangs motionless on the rope.

Calculate the tension T in the rope if the gymnast climbs the rope at a constant rate.

Calculate the tension T in the rope if the gymnast climbs up the rope with an upward acceleration of magnitude 1.20m/s2 .

Calculate the tension T in the rope if the gymnast slides down the rope with a downward acceleration of magnitude 1.20m/s2 .

*all answers in Newtons

In: Physics

Sharp Company manufactures a product for which the following standards have been set: Standard Quantity or...

Sharp Company manufactures a product for which the following standards have been set:

Standard Quantity
or Hours
Standard Price
or Rate
Standard
Cost
Direct materials 3 feet $ 5 per foot $ 15
Direct labor ? hours ? per hour ?

During March, the company purchased direct materials at a cost of $45,210, all of which were used in the production of 2,500 units of product. In addition, 4,100 direct labor-hours were worked on the product during the month. The cost of this labor time was $30,750. The following variances have been computed for the month:

Materials quantity variance $ 3,600 U
Labor spending variance $ 2,750

U

Labor efficiency variance $ 700

U

Required:

1. For direct materials:

a. Compute the actual cost per foot of materials for March.

b. Compute the price variance and the spending variance.

2. For direct labor:

a. Compute the standard direct labor rate per hour.

b. Compute the standard hours allowed for the month’s production.

c. Compute the standard hours allowed per unit of product.

In: Accounting

(a) In a proton at one certain moment, the down quark has a strong color charge...

(a) In a proton at one certain moment, the down quark has a strong color charge of red. What are the color charges of the two up quarks? (Type each color in lowercase with a space between each one.)

(d) In a pi meson at a certain time one quark has a red color. What is the color of the antiquark at that time?

In: Physics

Questions Which fuel was more efficient (produced more calories per gram)? Explain your answer. Fuel canister:...

Questions

Which fuel was more efficient (produced more calories per gram)? Explain your answer. Fuel canister: (diethylene glycol) or Tea candle: (paraffin) ?

Explain the difference in the efficiencies of the fuels you tested based on the chemical structures of the fuels.

Conduct research on both diethylene glycol and paraffin wax; for each fuel, summarize in your own words in one or two sentences how these fuels are synthesized. Cite the sources that you use for your research.

           

What are the possible sources of error in this experiment? How could the errors be reduced in future experiments?

In: Chemistry

describe Public Wi-Fi Hotspot Security

describe Public Wi-Fi Hotspot Security

In: Computer Science

In the 1990 Clean Air Act Amendments, Congress and the EPA rely on the automobile industry...

In the 1990 Clean Air Act Amendments, Congress and the EPA rely on the automobile industry to develop a cleaner automobile. At the same time, the government imposes a relatively minor federal tax on gasoline. a. Do you see any problem with the implicit signals the federal government is sending to American auto manufacturers and to American car drivers through these policies? Briefly discuss. b. Formulate a hypothetical economic policy to motivate automobile manufacturers to advance the technology of cleaner motor vehicles.

In: Economics

Show that a satellite may speed down: that is, show that if frictional forces or reverse...

Show that a satellite may speed down: that is, show that if frictional forces or reverse thrust cause a satellite to lose total energy, it will move into an orbit closer to the earth and may have increased kinetic energy.

In: Physics

What is the difference between a parameter and a statistic? Describe an example. Finally, there are...

What is the difference between a parameter and a statistic? Describe an example. Finally, there are “adjustments” that statisticians make to statistics to make them better represent the parameter, discuss what this looks like with the standard deviation.

In: Math

1. When 4.203g of NaOH is added to 100.0mL of water, the temperature of the solution...

1. When 4.203g of NaOH is added to 100.0mL of water, the temperature of the solution increases by 3.0C. Assume the density of the solution to be 1g/mL and the specific heat of capacity of the solution to be 4.184 J/gK.

a) Calculate the amount of heat absorbed by the solution.

b) Find the enthalpy change for the dissolution of NaOH.

c) Find the enthalpy change per mole of NaOH.

In: Chemistry

“It is better to pay regular price than to stand in a long line for a...

“It is better to pay regular price than to stand in a long line for a free item.” Discuss the statement using three (3) core principles of economics (with applicable examples) to support your views.

In: Economics

You prepare a buffer solution from 10.0 mL of 0.100 M MOPS (3-morpholinopropane-1-sulfonic acid) and 10.0...

You prepare a buffer solution from 10.0 mL of 0.100 M MOPS (3-morpholinopropane-1-sulfonic acid) and 10.0 mL of 0.084 M NaOH. Next, you add 1.00 mL of 4.69 × 10-6 M lidocaine to this mixture Denoting lidocaine as L, calculate the fraction of lidocaine present in the form LH .
The Ka of MOPS is 6.3 e-8, and the Kb of lidocaine is 8.7e-7

In: Chemistry