Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Stuck on this (JAVA) Shortest path utility program: Using the methods sqr distance2p and getPathLength to write a program named ShortestPath that compares two paths.

Stuck on this (JAVA)

Shortest path utility program: Using the methods sqr distance2p and getPathLength to write a program named ShortestPath that compares two paths. (You wrote those methods in previous labs.) Here are the details: The program reads two lines of input like the following:

lake_route 1.4 2.9 4.3 8.7 9.0 10.0 meadow_route 1.1 4.7 5.3 8.9 10.0 9.0

Each line consists of a string identifying (labeling) the path followed by three pairs of doubles. Each pair of doubles represents a point (x,y). Each line's sequence of three pairs represents a path of three points. The program uses getPathLength (which in turn uses the other two methods distance2p and sqr) to compute the total distance of each of the paths. The program then prints out 3 lines:

the path name and length of the first path

the path name and length of the second path

the path name of the shortest path

TWO OTHER METHODS :

public static double sqr(double x) { return Math.pow(x, 2.0); } public static double distance2p(double x1, double y1, double x2, double y2) { return Math.sqrt(sqr(x2-x1)+sqr(y2-y1)); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

T Sql Fundamentals

Authors: Itzik Ben Gan

4th Edition

0138102104, 978-0138102104

More Books

Students also viewed these Databases questions

Question

What Is Psychology?

Answered: 1 week ago

Question

The models used to analyse different national cultures.

Answered: 1 week ago

Question

The nature of the issues associated with expatriate employment.

Answered: 1 week ago