Question: Write a program named Distance.java that computes the distance between two points. Recall that the distance between the two points (x1, yl) and (x2, y2)

 Write a program named Distance.java that computes the distance between two

Write a program named Distance.java that computes the distance between two points. Recall that the distance between the two points (x1, yl) and (x2, y2) is computed by taking the square root of the quantity (x1- x2) (yl - y2)2. The program reads the two points from the user and compute the distance based on the input and print the distance to three decimal places. Let's say the distance unit is mile and the travel cost per mile is $0.43. Compute the total travel cost for the distance and print the cost to the three decimal places with currency. Test your program using the following data: The distance between the points (3, 17) and (8, 10) is 8.602 and the total travel cost is $3.698; the distance between (- 33, 49) and (-9,-15) is 68.352 and the total travel cost is $29.391. If it doesn't print more than two decimal places, use setMaximumFractionDigits) in the NumberFormat class. Example Output Enter xl: 20 Enter yl: 30 Enter x2 50 Enter y2: 80 Distance between the points is: 58.31 The travel cost is $25.07.3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!