Question: Write the following methods: 4. Given the coordinates of two points (x1, y1) and (x2, y2), return the distance between these two points. The formula

Write the following methods:

4. Given the coordinates of two points (x1, y1) and (x2, y2), return the distance between these two points. The formula for the distance is sqrt( (x2-x1)^2 + (y2-y1)^2). Note that you will need to use Math.sqrt as the method name and convert square to multiplication.

getDistance(0, 0, 0, 0) ? 0.0

getDistance(2.5, 1.5, -5.6, 7.8) ? 10.261578825892242

public static double getDistance(double x1, double y1, double x2, double y2) {

}

5. Given an integer, return the sum of the last two digits of the integer. Please name the method.

sumOfLastTwoDigits(23) ? 5

sumOfLastTwoDigits(123) ? 5

sumOfLastTwoDigits(975976) ? 13

public static int sumOfLastTwoDigits(int num) {

}

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!