In city street grids, intersections are often defined by two integers, counting the position of horizontal and vertical streets (sometimes called streets and avenues). Imagine traveling from position (h1, v1) to (h2, v2). How many blocks do you traverse?
Extracted text: In city street grids, intersections are often defined by two integers, counting the position of horizontal and vertical streets (sometimes called streets and avenues). Imagine traveling from position (h,, vi) to (h2, v2). How many blocks do you traverse? (h,, v.) (h,, v,) Even though there are many possible routes, the distance only depends on the differences h, - h, and v2 - V1. However, you need to take the absolute value because the differences might be negative. Complete the following program that prints the number of blocks traveled, given the origin and destination of the trip (which will change as your code is tested). Distance.java 1 public class Distance 2 { public static void main(String[] args) { // These values will be changed during testing int hl = 3; int vl = 4; int h2 = 4; int v2 = 4; 4 7 9. 10 11 .. 12 codecheck-bjlo-1e-02_06 System.out.print("Distance: "); System.out.println(distance); } 13 14 15 16 }
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here